Skip to content

Commit

Permalink
[PRISM] Rescue should set correct end_label
Browse files Browse the repository at this point in the history
In order for a break inside the rescue to have the correct jump target
  • Loading branch information
eightbitraptor authored and jemmaissroff committed Dec 7, 2023
1 parent 071df40 commit c4b9695
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions prism_compile.c
Expand Up @@ -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);

Expand Down
8 changes: 8 additions & 0 deletions test/ruby/test_compile_prism.rb
Expand Up @@ -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
Expand Down

0 comments on commit c4b9695

Please sign in to comment.