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