Skip to content

Commit 81feef4

Browse files
committed
Fix up block arguments node for ripper translation
1 parent 1f16df1 commit 81feef4

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

lib/prism/translation/ripper.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -693,22 +693,21 @@ def visit_call_node(node)
693693
block = nil
694694
end
695695

696-
arguments =
696+
[
697697
if arguments.length == 1 && arguments.first.is_a?(ForwardingArgumentsNode)
698698
visit(arguments.first)
699699
elsif arguments.any?
700700
args = visit_arguments(arguments)
701701

702-
if block.is_a?(BlockArgumentNode) || arguments.last.is_a?(ForwardingArgumentsNode)
702+
if block_node.is_a?(BlockArgumentNode) || arguments.last.is_a?(ForwardingArgumentsNode)
703703
args
704704
else
705705
bounds(arguments.first.location)
706706
on_args_add_block(args, false)
707707
end
708-
end
709-
710-
block = visit(block) if !block.nil?
711-
[arguments, block]
708+
end,
709+
visit(block)
710+
]
712711
end
713712

714713
# foo.bar += baz
@@ -1985,10 +1984,10 @@ def visit_next_node(node)
19851984
bounds(node.location)
19861985
on_next(on_args_new)
19871986
else
1988-
arguments = visit_arguments(node.arguments.arguments)
1987+
arguments = visit(node.arguments)
19891988

19901989
bounds(node.location)
1991-
on_next(on_args_add_block(arguments, false))
1990+
on_next(arguments)
19921991
end
19931992
end
19941993

test/prism/ripper_test.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class RipperTest < TestCase
3232
heredocs_with_ignored_newlines.txt
3333
if.txt
3434
method_calls.txt
35-
methods.txt
3635
modules.txt
3736
multi_write.txt
3837
patterns.txt
@@ -52,7 +51,6 @@ class RipperTest < TestCase
5251
seattlerb/call_args_command.txt
5352
seattlerb/call_array_lambda_block_call.txt
5453
seattlerb/call_assoc_trailing_comma.txt
55-
seattlerb/call_block_arg_named.txt
5654
seattlerb/call_trailing_comma.txt
5755
seattlerb/case_in.txt
5856
seattlerb/defn_oneliner_eq2.txt
@@ -113,25 +111,17 @@ class RipperTest < TestCase
113111
unparser/corpus/literal/pattern.txt
114112
unparser/corpus/literal/send.txt
115113
unparser/corpus/literal/since/27.txt
116-
unparser/corpus/literal/since/31.txt
117114
unparser/corpus/literal/while.txt
118115
unparser/corpus/semantic/dstr.txt
119116
unparser/corpus/semantic/literal.txt
120117
unparser/corpus/semantic/while.txt
121118
until.txt
122119
variables.txt
123120
while.txt
124-
whitequark/anonymous_blockarg.txt
125-
whitequark/args_args_assocs.txt
126121
whitequark/args_args_assocs_comma.txt
127122
whitequark/args_args_comma.txt
128-
whitequark/args_args_star.txt
129-
whitequark/args_assocs.txt
130123
whitequark/args_assocs_comma.txt
131-
whitequark/args_assocs_legacy.txt
132-
whitequark/args_block_pass.txt
133124
whitequark/args_cmd.txt
134-
whitequark/args_star.txt
135125
whitequark/asgn_mrhs.txt
136126
whitequark/bug_480.txt
137127
whitequark/dedenting_heredoc.txt

0 commit comments

Comments
 (0)