@@ -546,13 +546,13 @@ def visit_block_var(node)
546546 )
547547 end
548548
549- params = node . params
550549 children =
551- if ::Parser ::Builders ::Default . emit_procarg0 && node . arg0?
550+ if ::Parser ::Builders ::Default . emit_procarg0 && node . arg0? &&
551+ node . pipe?
552552 # There is a special node type in the parser gem for when a single
553553 # required parameter to a block would potentially be expanded
554554 # automatically. We handle that case here.
555- required = params . requireds . first
555+ required = node . params . requireds . first
556556 procarg0 =
557557 if ::Parser ::Builders ::Default . emit_arg_inside_procarg0 &&
558558 required . is_a? ( Ident )
@@ -577,18 +577,23 @@ def visit_block_var(node)
577577
578578 [ procarg0 ]
579579 else
580- visit ( params ) . children
580+ visit ( node . params ) . children
581581 end
582582
583- s (
584- :args ,
585- children + shadowargs ,
586- smap_collection (
587- srange_length ( node . start_char , 1 ) ,
588- srange_length ( node . end_char , -1 ) ,
589- srange_node ( node )
590- )
591- )
583+ location =
584+ if node . start_char == node . end_char
585+ smap_collection_bare ( nil )
586+ elsif buffer . source [ node . start_char - 1 ] == "("
587+ smap_collection (
588+ srange_length ( node . start_char , 1 ) ,
589+ srange_length ( node . end_char , -1 ) ,
590+ srange_node ( node )
591+ )
592+ else
593+ smap_collection_bare ( srange_node ( node ) )
594+ end
595+
596+ s ( :args , children + shadowargs , location )
592597 end
593598
594599 # Visit a BodyStmt node.
@@ -1520,7 +1525,7 @@ def visit_label(node)
15201525 # Visit a Lambda node.
15211526 def visit_lambda ( node )
15221527 args =
1523- node . params . is_a? ( LambdaVar ) ? node . params : node . params . contents
1528+ node . params . is_a? ( BlockVar ) ? node . params : node . params . contents
15241529 args_node = visit ( args )
15251530
15261531 type = :block
@@ -1559,33 +1564,6 @@ def visit_lambda(node)
15591564 )
15601565 end
15611566
1562- # Visit a LambdaVar node.
1563- def visit_lambda_var ( node )
1564- shadowargs =
1565- node . locals . map do |local |
1566- s (
1567- :shadowarg ,
1568- [ local . value . to_sym ] ,
1569- smap_variable ( srange_node ( local ) , srange_node ( local ) )
1570- )
1571- end
1572-
1573- location =
1574- if node . start_char == node . end_char
1575- smap_collection_bare ( nil )
1576- elsif buffer . source [ node . start_char - 1 ] == "("
1577- smap_collection (
1578- srange_length ( node . start_char , 1 ) ,
1579- srange_length ( node . end_char , -1 ) ,
1580- srange_node ( node )
1581- )
1582- else
1583- smap_collection_bare ( srange_node ( node ) )
1584- end
1585-
1586- s ( :args , visit ( node . params ) . children + shadowargs , location )
1587- end
1588-
15891567 # Visit an MAssign node.
15901568 def visit_massign ( node )
15911569 s (
0 commit comments