diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-03-06 00:41:07 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-03-06 16:42:58 +0000 |
| commit | cdb47b1b3a641cc86092c2a60070752e10e873e8 (patch) | |
| tree | 5d60dcaec280b4387aecce10364729f3f4005f30 | |
| parent | f96ce41ac88267a6dce2d13f6f0400f2265476a9 (diff) | |
[ruby/prism] Handle numbered parameters in ripper translation
https://github.com/ruby/prism/commit/cf21c08c0b
| -rw-r--r-- | lib/prism/translation/ripper.rb | 8 | ||||
| -rw-r--r-- | test/prism/ripper_test.rb | 17 |
2 files changed, 9 insertions, 16 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb index be4032de8d..79eaac3bd0 100644 --- a/lib/prism/translation/ripper.rb +++ b/lib/prism/translation/ripper.rb @@ -1791,10 +1791,7 @@ module Prism # -> {} def visit_lambda_node(node) parameters = - if node.parameters.nil? - bounds(node.location) - on_params(nil, nil, nil, nil, nil, nil, nil) - else + if node.parameters.is_a?(BlockParametersNode) # Ripper does not track block-locals within lambdas, so we skip # directly to the parameters here. params = visit(node.parameters.parameters) @@ -1805,6 +1802,9 @@ module Prism bounds(node.parameters.opening_loc) on_paren(params) end + else + bounds(node.location) + on_params(nil, nil, nil, nil, nil, nil, nil) end braces = node.opening == "{" diff --git a/test/prism/ripper_test.rb b/test/prism/ripper_test.rb index 076bcef085..9b633c37cb 100644 --- a/test/prism/ripper_test.rb +++ b/test/prism/ripper_test.rb @@ -11,17 +11,14 @@ module Prism relatives = ENV["FOCUS"] ? [ENV["FOCUS"]] : Dir["**/*.txt", base: base] incorrect = [ - # Ripper incorrectly attributes the block to the `break` statement. + # Ripper incorrectly attributes the block to the keyword. + "seattlerb/block_break.txt", "whitequark/break_block.txt", - - # Ripper cannot handle named capture groups in regular expressions. - "whitequark/lvar_injecting_match.txt", - - # Ripper incorrectly attributes the block to the `next` statement. "whitequark/next_block.txt", + "whitequark/return_block.txt", - # Ripper incorrectly attributes the block to the `return` statement. - "whitequark/return_block.txt" + # Ripper cannot handle named capture groups in regular expressions. + "whitequark/lvar_injecting_match.txt" ] skips = incorrect | %w[ @@ -39,7 +36,6 @@ module Prism regex_char_width.txt rescue.txt seattlerb/TestRubyParserShared.txt - seattlerb/block_break.txt seattlerb/block_call_dot_op2_brace_block.txt seattlerb/block_command_operation_colon.txt seattlerb/block_command_operation_dot.txt @@ -89,7 +85,6 @@ module Prism unparser/corpus/literal/module.txt unparser/corpus/literal/pattern.txt unparser/corpus/literal/send.txt - unparser/corpus/literal/since/27.txt unparser/corpus/literal/while.txt unparser/corpus/semantic/dstr.txt unparser/corpus/semantic/while.txt @@ -102,13 +97,11 @@ module Prism whitequark/empty_stmt.txt whitequark/if_elsif.txt whitequark/masgn_splat.txt - whitequark/numbered_args_after_27.txt whitequark/parser_bug_640.txt whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt whitequark/parser_slash_slash_n_escaping_in_literals.txt whitequark/ruby_bug_11107.txt whitequark/ruby_bug_11990.txt - whitequark/ruby_bug_15789.txt whitequark/send_block_chain_cmd.txt whitequark/slash_newline_in_heredocs.txt whitequark/string_concat.txt |
