mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Adjust sp for if true or ...
/if false and ...
This commit is contained in:
parent
ce7a053475
commit
65ae7f347a
Notes:
git
2020-10-16 08:37:46 +09:00
2 changed files with 13 additions and 2 deletions
10
compile.c
10
compile.c
|
@ -3889,7 +3889,10 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
|
||||||
LABEL *label = NEW_LABEL(nd_line(cond));
|
LABEL *label = NEW_LABEL(nd_line(cond));
|
||||||
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, label,
|
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, label,
|
||||||
else_label));
|
else_label));
|
||||||
if (!label->refcnt) break;
|
if (!label->refcnt) {
|
||||||
|
ADD_INSN(ret, nd_line(cond), putnil);
|
||||||
|
break;
|
||||||
|
}
|
||||||
ADD_LABEL(ret, label);
|
ADD_LABEL(ret, label);
|
||||||
cond = cond->nd_2nd;
|
cond = cond->nd_2nd;
|
||||||
goto again;
|
goto again;
|
||||||
|
@ -3899,7 +3902,10 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
|
||||||
LABEL *label = NEW_LABEL(nd_line(cond));
|
LABEL *label = NEW_LABEL(nd_line(cond));
|
||||||
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
|
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
|
||||||
label));
|
label));
|
||||||
if (!label->refcnt) break;
|
if (!label->refcnt) {
|
||||||
|
ADD_INSN(ret, nd_line(cond), putnil);
|
||||||
|
break;
|
||||||
|
}
|
||||||
ADD_LABEL(ret, label);
|
ADD_LABEL(ret, label);
|
||||||
cond = cond->nd_2nd;
|
cond = cond->nd_2nd;
|
||||||
goto again;
|
goto again;
|
||||||
|
|
|
@ -1514,6 +1514,11 @@ eom
|
||||||
assert_valid_syntax("tap {a = (break unless true)}")
|
assert_valid_syntax("tap {a = (break unless true)}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_tautological_condition
|
||||||
|
assert_valid_syntax("def f() return if false and invalid; nil end")
|
||||||
|
assert_valid_syntax("def f() return unless true or invalid; nil end")
|
||||||
|
end
|
||||||
|
|
||||||
def test_argument_forwarding
|
def test_argument_forwarding
|
||||||
assert_valid_syntax('def foo(...) bar(...) end')
|
assert_valid_syntax('def foo(...) bar(...) end')
|
||||||
assert_valid_syntax('def foo(...) end')
|
assert_valid_syntax('def foo(...) end')
|
||||||
|
|
Loading…
Add table
Reference in a new issue