diff options
author | Matt Valentine-House <[email protected]> | 2024-01-30 20:51:30 +0000 |
---|---|---|
committer | Matt Valentine-House <[email protected]> | 2024-01-30 22:22:39 +0000 |
commit | 8041b7d9677d158850e14fc763038df30f14c16d (patch) | |
tree | 0353b5e627dc29575a4fa03cd39e5c323547a7d9 | |
parent | 1142ed2f50359d8cab7903e5cc1f0ec9a2ed3e6e (diff) |
[PRISM] pm_compile_logical: Fix OrNode in IfNode predicate
Fixes: https://github.com/ruby/prism/issues/2294
-rw-r--r-- | prism_compile.c | 4 | ||||
-rw-r--r-- | test/ruby/test_compile_prism.rb | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/prism_compile.c b/prism_compile.c index 2bde291c38..785e971670 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -495,7 +495,9 @@ pm_compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, pm_node_t *cond, return; } if (!label->refcnt) { - PM_PUTNIL; + if (popped) { + PM_PUTNIL; + } } else { ADD_LABEL(seq, label); diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index fc11eb21b7..e4748e3898 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -1011,6 +1011,7 @@ module Prism assert_prism_eval('if ..1; end') assert_prism_eval('if 1..; end') assert_prism_eval('if 1..2; end') + assert_prism_eval('if true or true; end'); end def test_OrNode |