summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorwanabe <s.wanabe@gmail.com>2020-08-08 11:29:51 +0900
committerwanabe <s.wanabe@gmail.com>2020-10-16 08:37:04 +0900
commit65ae7f347a9b44c62ed68870c0a59fd333e6784d (patch)
tree65c8b3697ac3d1c997a8e76638b40021283e679d /compile.c
parentce7a053475cbebfb2f3e5ed6614e0ba631541917 (diff)
Adjust sp for `if true or ...`/`if false and ...`
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3445
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index 015cbc7333..0b9c276e1f 100644
--- a/compile.c
+++ b/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;