[PRISM] pm_compile_logical: Fix OrNode in IfNode predicate

Fixes: https://github.com/ruby/prism/issues/2294
This commit is contained in:
Matt Valentine-House 2024-01-30 20:51:30 +00:00
parent 1142ed2f50
commit 8041b7d967
2 changed files with 4 additions and 1 deletions

View File

@ -495,7 +495,9 @@ pm_compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, pm_node_t *cond,
return; return;
} }
if (!label->refcnt) { if (!label->refcnt) {
PM_PUTNIL; if (popped) {
PM_PUTNIL;
}
} }
else { else {
ADD_LABEL(seq, label); ADD_LABEL(seq, label);

View File

@ -1011,6 +1011,7 @@ module Prism
assert_prism_eval('if ..1; end') assert_prism_eval('if ..1; end')
assert_prism_eval('if 1..; end') assert_prism_eval('if 1..; end')
assert_prism_eval('if 1..2; end') assert_prism_eval('if 1..2; end')
assert_prism_eval('if true or true; end');
end end
def test_OrNode def test_OrNode