summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-03-05 23:04:19 -0500
committergit <svn-admin@ruby-lang.org>2024-03-06 16:42:54 +0000
commitc6299dda3dbe4dfb1caf78e1920c744dbcf334d5 (patch)
tree130f7e02554c17c5314874e6c51f887eeb152dc0
parentff9df28955b519746762faed16fa8471ba85a0d7 (diff)
[ruby/prism] Fix up begin node clause semicolon detection in ripper translation
https://github.com/ruby/prism/commit/117c7418af
-rw-r--r--lib/prism/translation/ripper.rb8
-rw-r--r--test/prism/ripper_test.rb7
2 files changed, 4 insertions, 11 deletions
diff --git a/lib/prism/translation/ripper.rb b/lib/prism/translation/ripper.rb
index acac05e013..e7abf01138 100644
--- a/lib/prism/translation/ripper.rb
+++ b/lib/prism/translation/ripper.rb
@@ -372,20 +372,20 @@ module Prism
# begin end
# ^^^^^^^^^
def visit_begin_node(node)
- clauses = visit_begin_node_clauses(node)
+ clauses = visit_begin_node_clauses(node.begin_keyword_loc, node)
bounds(node.location)
on_begin(clauses)
end
# Visit the clauses of a begin node to form an on_bodystmt call.
- private def visit_begin_node_clauses(node)
+ private def visit_begin_node_clauses(location, node)
statements =
if node.statements.nil?
on_stmts_add(on_stmts_new, on_void_stmt)
else
body = node.statements.body
- body.unshift(nil) if semicolon?(node.begin_keyword_loc, node.statements.body[0].location)
+ body.unshift(nil) if semicolon?(location, node.statements.body[0].location)
bounds(node.statements.location)
visit_statements_node_body(body)
@@ -427,7 +427,7 @@ module Prism
bounds(node.body.first.location)
on_bodystmt(stmts, nil, nil, nil)
when BeginNode
- visit_begin_node_clauses(node)
+ visit_begin_node_clauses(location, node)
else
raise
end
diff --git a/test/prism/ripper_test.rb b/test/prism/ripper_test.rb
index 75f3ca841b..2d0a2efe18 100644
--- a/test/prism/ripper_test.rb
+++ b/test/prism/ripper_test.rb
@@ -63,9 +63,7 @@ module Prism
seattlerb/case_in.txt
seattlerb/class_comments.txt
seattlerb/defn_oneliner_eq2.txt
- seattlerb/defn_oneliner_rescue.txt
seattlerb/defs_oneliner_eq2.txt
- seattlerb/defs_oneliner_rescue.txt
seattlerb/difficult3_.txt
seattlerb/difficult3_5.txt
seattlerb/difficult3__10.txt
@@ -117,10 +115,6 @@ module Prism
seattlerb/parse_pattern_051.txt
seattlerb/parse_pattern_058.txt
seattlerb/parse_pattern_076.txt
- seattlerb/rescue_do_end_ensure_result.txt
- seattlerb/rescue_do_end_no_raise.txt
- seattlerb/rescue_do_end_raised.txt
- seattlerb/rescue_do_end_rescued.txt
seattlerb/return_call_assocs.txt
seattlerb/stabby_block_iter_call.txt
seattlerb/stabby_block_iter_call_no_target_with_arg.txt
@@ -189,7 +183,6 @@ module Prism
whitequark/parser_bug_640.txt
whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt
whitequark/parser_slash_slash_n_escaping_in_literals.txt
- whitequark/rescue_without_begin_end.txt
whitequark/ruby_bug_11107.txt
whitequark/ruby_bug_11873.txt
whitequark/ruby_bug_11873_a.txt