Skip to content

Commit e0a836e

Browse files
committed
Handle empty parentheses in lambda in ripper translation
1 parent 99eca8b commit e0a836e

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/prism/translation/ripper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,13 @@ def visit_lambda_node(node)
18081808
if node.parameters.is_a?(BlockParametersNode)
18091809
# Ripper does not track block-locals within lambdas, so we skip
18101810
# directly to the parameters here.
1811-
params = visit(node.parameters.parameters)
1811+
params =
1812+
if node.parameters.parameters.nil?
1813+
bounds(node.location)
1814+
on_params(nil, nil, nil, nil, nil, nil, nil)
1815+
else
1816+
visit(node.parameters.parameters)
1817+
end
18121818

18131819
if node.parameters.opening_loc.nil?
18141820
params

test/prism/ripper_test.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ class RipperTest < TestCase
4141
seattlerb/block_call_dot_op2_brace_block.txt
4242
seattlerb/block_command_operation_colon.txt
4343
seattlerb/block_command_operation_dot.txt
44-
seattlerb/call_array_lambda_block_call.txt
4544
seattlerb/defn_oneliner_eq2.txt
4645
seattlerb/defs_oneliner_eq2.txt
47-
seattlerb/difficult3_5.txt
48-
seattlerb/do_lambda.txt
4946
seattlerb/heredoc__backslash_dos_format.txt
5047
seattlerb/heredoc_backslash_nl.txt
5148
seattlerb/heredoc_nested.txt
@@ -57,19 +54,15 @@ class RipperTest < TestCase
5754
seattlerb/heredoc_squiggly_tabs_extra.txt
5855
seattlerb/heredoc_squiggly_visually_blank_lines.txt
5956
seattlerb/if_elsif.txt
60-
seattlerb/lambda_do_vs_brace.txt
6157
seattlerb/parse_pattern_051.txt
6258
seattlerb/parse_pattern_058.txt
63-
seattlerb/stabby_block_iter_call.txt
64-
seattlerb/stabby_block_iter_call_no_target_with_arg.txt
6559
spanning_heredoc.txt
6660
tilde_heredocs.txt
6761
unparser/corpus/literal/block.txt
6862
unparser/corpus/literal/class.txt
6963
unparser/corpus/literal/empty.txt
7064
unparser/corpus/literal/if.txt
7165
unparser/corpus/literal/kwbegin.txt
72-
unparser/corpus/literal/lambda.txt
7366
unparser/corpus/literal/module.txt
7467
unparser/corpus/literal/pattern.txt
7568
unparser/corpus/literal/send.txt
@@ -84,7 +77,6 @@ class RipperTest < TestCase
8477
whitequark/parser_bug_640.txt
8578
whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt
8679
whitequark/parser_slash_slash_n_escaping_in_literals.txt
87-
whitequark/ruby_bug_11107.txt
8880
whitequark/send_block_chain_cmd.txt
8981
whitequark/slash_newline_in_heredocs.txt
9082
]

0 commit comments

Comments
 (0)