From c4b969535055ab0debf47abc26d00c1b06c686cc Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Wed, 6 Dec 2023 22:20:38 +0000 Subject: [PATCH] [PRISM] Rescue should set correct end_label In order for a break inside the rescue to have the correct jump target --- prism_compile.c | 2 ++ test/ruby/test_compile_prism.rb | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/prism_compile.c b/prism_compile.c index a365946ba381ad..285b023e4ac889 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 339300a6388fcf..97ee5c2f700f22 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -950,6 +950,14 @@ def test_RescueNode end end CODE + assert_prism_eval(<<~CODE) + 10.times do + begin + rescue + break + end + end + CODE end def test_RescueModiferNode