Skip to content

Commit

Permalink
[PRISM] Remove dummy_line_node usage from false and else node
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Apr 4, 2024
1 parent 829ca8c commit cc24870
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions prism_compile.c
Expand Up @@ -5655,11 +5655,14 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
PM_COMPILE(cast->variable);
return;
}
case PM_FALSE_NODE:
case PM_FALSE_NODE: {
// false
// ^^^^^
if (!popped) {
ADD_INSN1(ret, &dummy_line_node, putobject, Qfalse);
PUSH_INSN1(ret, location, putobject, Qfalse);
}
return;
}
case PM_ENSURE_NODE: {
pm_ensure_node_t *ensure_node = (pm_ensure_node_t *)node;

Expand All @@ -5676,14 +5679,18 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
return;
}
case PM_ELSE_NODE: {
pm_else_node_t *cast = (pm_else_node_t *)node;
if (cast->statements) {
PM_COMPILE((pm_node_t *)cast->statements);
}
else {
PM_PUTNIL_UNLESS_POPPED;
}
return;
// if foo then bar else baz end
// ^^^^^^^^^^^^
const pm_else_node_t *cast = (const pm_else_node_t *) node;

if (cast->statements != NULL) {
PM_COMPILE((const pm_node_t *) cast->statements);
}
else if (!popped) {
PUSH_INSN(ret, location, putnil);
}

return;
}
case PM_FLIP_FLOP_NODE: {
pm_flip_flop_node_t *flip_flop_node = (pm_flip_flop_node_t *)node;
Expand Down

0 comments on commit cc24870

Please sign in to comment.