summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Valentine-House <matt@eightbitraptor.com>2023-12-06 22:20:38 +0000
committerJemma Issroff <jemmaissroff@gmail.com>2023-12-07 09:38:24 -0500
commitc4b969535055ab0debf47abc26d00c1b06c686cc (patch)
tree8b8d65a2db3f0326f4bccbaa5ee13ef6d9335919
parent071df40495e31f6d3fd14ae8686b01edf9a689e3 (diff)
[PRISM] Rescue should set correct end_label
In order for a break inside the rescue to have the correct jump target
-rw-r--r--prism_compile.c2
-rw-r--r--test/ruby/test_compile_prism.rb8
2 files changed, 10 insertions, 0 deletions
diff --git a/prism_compile.c b/prism_compile.c
index a365946ba3..285b023e4a 100644
--- a/prism_compile.c
+++ b/prism_compile.c
@@ -3851,6 +3851,8 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
LABEL *excep_match = NEW_LABEL(lineno);
LABEL *rescue_end = NEW_LABEL(lineno);
+ ISEQ_COMPILE_DATA(iseq)->end_label = rescue_end;
+
pm_rescue_node_t *rescue_node = (pm_rescue_node_t *)node;
iseq_set_exception_local_table(iseq);
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index 339300a638..97ee5c2f70 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -950,6 +950,14 @@ module Prism
end
end
CODE
+ assert_prism_eval(<<~CODE)
+ 10.times do
+ begin
+ rescue
+ break
+ end
+ end
+ CODE
end
def test_RescueModiferNode