From 1a3bca1dd6c43d4b6ec638d9b0987c0488af6fae Mon Sep 17 00:00:00 2001 From: nagachika Date: Sun, 24 Dec 2017 02:45:07 +0000 Subject: merge revision(s) 60099,60100: [Backport #13964] compile.c: fix stack consitency error * compile.c (iseq_compile_each0): fix stack consitency error on attr-assign with safe navigation operator when the receiver is nil, should pop it too. [ruby-core:83078] [Bug #13964] test_call.rb: refine test_safe_call * test/ruby/test_call.rb (test_safe_call): rhs should not be evaluated when the receiver is nil. simplified the assertion for [Bug #13964]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@61439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index c75e233251..4631f9080b 100644 --- a/compile.c +++ b/compile.c @@ -5037,8 +5037,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe ADD_INSN1(ret, line, topn, INT2FIX(1)); } ADD_SEND_WITH_FLAG(ret, line, aid, INT2FIX(1), INT2FIX(asgnflag)); + if (lskip && popped) { + ADD_LABEL(ret, lskip); + } ADD_INSN(ret, line, pop); - if (lskip) { + if (lskip && !popped) { ADD_LABEL(ret, lskip); } } -- cgit v1.2.3