зеркало из https://github.com/github/ruby.git
Adjust sp for `if true or ...`/`if false and ...`
This commit is contained in:
Родитель
ce7a053475
Коммит
65ae7f347a
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));
|
||||
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, label,
|
||||
else_label));
|
||||
if (!label->refcnt) break;
|
||||
if (!label->refcnt) {
|
||||
ADD_INSN(ret, nd_line(cond), putnil);
|
||||
break;
|
||||
}
|
||||
ADD_LABEL(ret, label);
|
||||
cond = cond->nd_2nd;
|
||||
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));
|
||||
CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
|
||||
label));
|
||||
if (!label->refcnt) break;
|
||||
if (!label->refcnt) {
|
||||
ADD_INSN(ret, nd_line(cond), putnil);
|
||||
break;
|
||||
}
|
||||
ADD_LABEL(ret, label);
|
||||
cond = cond->nd_2nd;
|
||||
goto again;
|
||||
|
|
|
@ -1514,6 +1514,11 @@ eom
|
|||
assert_valid_syntax("tap {a = (break unless true)}")
|
||||
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
|
||||
assert_valid_syntax('def foo(...) bar(...) end')
|
||||
assert_valid_syntax('def foo(...) end')
|
||||
|
|
Загрузка…
Ссылка в новой задаче