Skip to content

Commit

Permalink
[PRISM] Ensure should set correct end_label
Browse files Browse the repository at this point in the history
  • Loading branch information
eightbitraptor authored and jemmaissroff committed Dec 7, 2023
1 parent c4b9695 commit 8e86a43
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions prism_compile.c
Expand Up @@ -1394,8 +1394,7 @@ pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_
break;
}
case PM_ENSURE_NODE: {
pm_ensure_node_t *cast = (pm_ensure_node_t *)node;
scope->body = (pm_node_t *)cast->statements;
scope->body = (pm_node_t *)node;
scope->local_depth_offset += 1;
break;
}
Expand Down Expand Up @@ -2631,6 +2630,18 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
ADD_INSN1(ret, &dummy_line_node, putobject, Qfalse);
}
return;
case PM_ENSURE_NODE: {
pm_ensure_node_t *ensure_node = (pm_ensure_node_t *)node;

LABEL *start = NEW_LABEL(lineno);
LABEL *end = NEW_LABEL(lineno);
ADD_LABEL(ret, start);
if (ensure_node->statements) {
ISEQ_COMPILE_DATA(iseq)->end_label = end;
PM_COMPILE((pm_node_t *)ensure_node->statements);
}
ADD_LABEL(ret, end);
}
case PM_ELSE_NODE: {
pm_else_node_t *cast = (pm_else_node_t *)node;
if (cast->statements) {
Expand Down

0 comments on commit 8e86a43

Please sign in to comment.