summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compile.c2
-rw-r--r--test/ruby/test_iseq.rb4
2 files changed, 6 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index bcf22243cf..cefe6c4c6a 100644
--- a/compile.c
+++ b/compile.c
@@ -4844,6 +4844,7 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *cond,
CHECK(ok = compile_logical(iseq, ret, RNODE_AND(cond)->nd_1st, NULL, else_label));
cond = RNODE_AND(cond)->nd_2nd;
if (ok == COMPILE_SINGLE) {
+ ADD_INSNL(ret, cond, jump, else_label);
INIT_ANCHOR(ignore);
ret = ignore;
then_label = NEW_LABEL(nd_line(cond));
@@ -4853,6 +4854,7 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *cond,
CHECK(ok = compile_logical(iseq, ret, RNODE_OR(cond)->nd_1st, then_label, NULL));
cond = RNODE_OR(cond)->nd_2nd;
if (ok == COMPILE_SINGLE) {
+ ADD_INSNL(ret, cond, jump, then_label);
INIT_ANCHOR(ignore);
ret = ignore;
else_label = NEW_LABEL(nd_line(cond));
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index c43fc32b59..9235ef3f5b 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -875,6 +875,10 @@ class TestISeq < Test::Unit::TestCase
assert_ruby_status([], "BEGIN {exit}; while true && true; end")
end
+ def test_short_circuited_loop_condition
+ assert_ruby_status([], "while true || true; exit; end; abort")
+ end
+
def test_unreachable_syntax_error
mesg = /Invalid break/
assert_syntax_error("false and break", mesg)