From d8ae19d0334ade1a9ce91b93e3f098a85f49b9e1 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 3 Jun 2024 17:29:39 -0400 Subject: [PATCH] Revert "Properly destructure procarg0 in parser translation" This reverts commit 823e931ff230d0980eef14a4cac2cad5716c55d7. --- lib/prism/translation/parser/compiler.rb | 27 ++++++++++++------------ test/prism/ruby/parser_test.rb | 6 ++++++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb index df5917ab262..816c8841e83 100644 --- a/lib/prism/translation/parser/compiler.rb +++ b/lib/prism/translation/parser/compiler.rb @@ -1390,12 +1390,12 @@ def visit_parameters_node(node) if node.requireds.any? node.requireds.each do |required| - params << - if required.is_a?(RequiredParameterNode) - visit(required) - else - required.accept(copy_compiler(in_destructure: true)) - end + if required.is_a?(RequiredParameterNode) + params << visit(required) + else + compiler = copy_compiler(in_destructure: true) + params << required.accept(compiler) + end end end @@ -1404,12 +1404,12 @@ def visit_parameters_node(node) if node.posts.any? node.posts.each do |post| - params << - if post.is_a?(RequiredParameterNode) - visit(post) - else - post.accept(copy_compiler(in_destructure: true)) - end + if post.is_a?(RequiredParameterNode) + params << visit(post) + else + compiler = copy_compiler(in_destructure: true) + params << post.accept(compiler) + end end end @@ -2004,8 +2004,7 @@ def visit_block(call, block) token(parameters.opening_loc), if procarg0?(parameters.parameters) parameter = parameters.parameters.requireds.first - visited = parameter.is_a?(RequiredParameterNode) ? visit(parameter) : parameter.accept(copy_compiler(in_destructure: true)) - [builder.procarg0(visited)].concat(visit_all(parameters.locals)) + [builder.procarg0(visit(parameter))].concat(visit_all(parameters.locals)) else visit(parameters) end, diff --git a/test/prism/ruby/parser_test.rb b/test/prism/ruby/parser_test.rb index d0e3288df75..d5787a0c166 100644 --- a/test/prism/ruby/parser_test.rb +++ b/test/prism/ruby/parser_test.rb @@ -52,6 +52,11 @@ class ParserTest < TestCase "spanning_heredoc.txt", "spanning_heredoc_newlines.txt", "unescaping.txt", + "seattlerb/block_decomp_anon_splat_arg.txt", + "seattlerb/block_decomp_arg_splat_arg.txt", + "seattlerb/block_decomp_arg_splat.txt", + "seattlerb/block_decomp_splat.txt", + "seattlerb/block_paren_splat.txt", "seattlerb/bug190.txt", "seattlerb/heredoc_nested.txt", "seattlerb/heredoc_with_carriage_return_escapes_windows.txt", @@ -64,6 +69,7 @@ class ParserTest < TestCase "seattlerb/pctW_lineno.txt", "seattlerb/regexp_esc_C_slash.txt", "seattlerb/TestRubyParserShared.txt", + "unparser/corpus/literal/block.txt", "unparser/corpus/literal/literal.txt", "unparser/corpus/literal/pattern.txt", "unparser/corpus/semantic/dstr.txt",