summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorwanabe <s.wanabe@gmail.com>2020-08-08 16:08:47 +0900
committerKazuki Tsujimoto <kazuki@callcc.net>2020-08-16 18:39:08 +0900
commit0759862458c25bb8a7832090545c625c364e5d94 (patch)
treea1be34d26a500f7f33ebff9d1777552e4564da52 /compile.c
parentc1e7f0c709389a230f8032f3e1fc66148e935425 (diff)
Adjust sp for pattern matching implicit/explicit "else"
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3403
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index c7a4a8c324..fa3c513449 100644
--- a/compile.c
+++ b/compile.c
@@ -6385,6 +6385,10 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
add_trace_branch_coverage(iseq, cond_seq, node, branch_id, "else", branches);
CHECK(COMPILE_(cond_seq, "else", node, popped));
ADD_INSNL(cond_seq, line, jump, endlabel);
+ ADD_INSN(cond_seq, line, putnil);
+ if (popped) {
+ ADD_INSN(cond_seq, line, putnil);
+ }
}
else {
debugs("== else (implicit)\n");
@@ -6401,6 +6405,10 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
ADD_INSN(cond_seq, nd_line(orig_node), putnil);
}
ADD_INSNL(cond_seq, nd_line(orig_node), jump, endlabel);
+ ADD_INSN(cond_seq, line, putnil);
+ if (popped) {
+ ADD_INSN(cond_seq, line, putnil);
+ }
}
ADD_SEQ(ret, cond_seq);