summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-03-06 01:08:30 -0500
committergit <svn-admin@ruby-lang.org>2024-03-06 16:43:00 +0000
commit554ad9dc1c46be7a7fa0429d18804c1e171daa33 (patch)
tree4f51ca1466bdc9234597be45bfd22f6408dc5a99
parent46e9f71a9194162d610e908b10afe3a1446d1490 (diff)
[ruby/prism] Allow rescue modifier after MRHS in ripper translation
https://github.com/ruby/prism/commit/37db4d8c2d
-rw-r--r--lib/prism/translation/ripper.rb13
-rw-r--r--test/prism/ripper_test.rb11
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb
index 08a53a27c1..344913f3e5 100644
--- a/lib/prism/translation/ripper.rb
+++ b/lib/prism/translation/ripper.rb
@@ -341,14 +341,15 @@ module Prism
constant = visit(node.constant)
requireds = visit_all(node.requireds) if node.requireds.any?
rest =
- if !node.rest.nil?
- if !node.rest.expression.nil?
- visit(node.rest.expression)
- else
- bounds(node.rest.location)
+ if (rest_node = node.rest).is_a?(SplatNode)
+ if rest_node.expression.nil?
+ bounds(rest_node.location)
on_var_field(nil)
+ else
+ visit(rest_node.expression)
end
end
+
posts = visit_all(node.posts) if node.posts.any?
bounds(node.location)
@@ -2284,7 +2285,7 @@ module Prism
# foo rescue bar
# ^^^^^^^^^^^^^^
def visit_rescue_modifier_node(node)
- expression = visit(node.expression)
+ expression = visit_write_value(node.expression)
rescue_expression = visit(node.rescue_expression)
bounds(node.location)
diff --git a/test/prism/ripper_test.rb b/test/prism/ripper_test.rb
index 2086204460..d1db383dbe 100644
--- a/test/prism/ripper_test.rb
+++ b/test/prism/ripper_test.rb
@@ -19,7 +19,12 @@ module Prism
"whitequark/next_block.txt",
"whitequark/return_block.txt",
+ # Ripper is not accounting for locals created by patterns using the **
+ # operator within an `in` clause.
+ "seattlerb/parse_pattern_058.txt",
+
# Ripper cannot handle named capture groups in regular expressions.
+ "regex_char_width.txt",
"whitequark/lvar_injecting_match.txt"
]
@@ -32,10 +37,7 @@ module Prism
heredocs_with_ignored_newlines.txt
if.txt
modules.txt
- multi_write.txt
- patterns.txt
regex.txt
- regex_char_width.txt
rescue.txt
seattlerb/TestRubyParserShared.txt
seattlerb/block_call_dot_op2_brace_block.txt
@@ -54,8 +56,6 @@ module Prism
seattlerb/heredoc_squiggly_tabs_extra.txt
seattlerb/heredoc_squiggly_visually_blank_lines.txt
seattlerb/if_elsif.txt
- seattlerb/parse_pattern_051.txt
- seattlerb/parse_pattern_058.txt
spanning_heredoc.txt
tilde_heredocs.txt
unparser/corpus/literal/block.txt
@@ -64,7 +64,6 @@ module Prism
unparser/corpus/literal/if.txt
unparser/corpus/literal/kwbegin.txt
unparser/corpus/literal/module.txt
- unparser/corpus/literal/pattern.txt
unparser/corpus/literal/send.txt
unparser/corpus/literal/while.txt
unparser/corpus/semantic/dstr.txt