aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-02 08:33:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-02 08:33:30 +0000
commitd9e226503da1e6ee60f43f4f820a70353b5d7e33 (patch)
treea9fc4fb6d026f8139e48adeedb56798d8839e119
parent88afe165faae5cb4833d8dec65dd38f348e79323 (diff)
downloadruby-d9e226503da1e6ee60f43f4f820a70353b5d7e33.tar.gz
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c5
-rw-r--r--test/ruby/test_call.rb1
2 files changed, 5 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 235491520f..0e56820055 100644
--- a/compile.c
+++ b/compile.c
@@ -5415,8 +5415,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popp
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);
}
}
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb
index 4496d78210..18203ce731 100644
--- a/test/ruby/test_call.rb
+++ b/test/ruby/test_call.rb
@@ -52,6 +52,7 @@ class TestCall < Test::Unit::TestCase
assert_nil(o&.x)
assert_nothing_raised(NoMethodError) {o&.x = 6}
assert_nothing_raised(NoMethodError) {o&.x *= 7}
+ assert_nothing_raised(NoMethodError) {o&.x *= 8; [].each {}}
end
def test_safe_call_evaluate_arguments_only_method_call_is_made