summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-31 13:16:25 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-31 13:16:25 +0000
commit935319fbb8271622370792c013a8b933263e0b5e (patch)
treeb87930e99278abfe7562b9fcb2a234ab0e433447
parent1aee5acdae7fa88e0241ed4c21ed88f775054cba (diff)
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_3@62135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog14
-rw-r--r--compile.c5
-rw-r--r--test/ruby/test_call.rb5
-rw-r--r--version.h2
4 files changed, 22 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 9649c0e6a3..8acff6909c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Wed Jan 31 22:16:00 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ 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].
+
Wed Jan 31 22:12:48 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
adjust indent
diff --git a/compile.c b/compile.c
index 0aea3acd92..3c62d614a7 100644
--- a/compile.c
+++ b/compile.c
@@ -4751,8 +4751,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
ADD_INSN1(ret, line, topn, INT2FIX(1));
}
ADD_SEND_WITH_FLAG(ret, line, aid, INT2FIX(1), INT2FIX(asgnflag));
+ if (lskip && poped) {
+ ADD_LABEL(ret, lskip);
+ }
ADD_INSN(ret, line, pop);
- if (lskip) {
+ if (lskip && !poped) {
ADD_LABEL(ret, lskip);
}
}
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb
index 4496d78210..2a1b671cac 100644
--- a/test/ruby/test_call.rb
+++ b/test/ruby/test_call.rb
@@ -50,8 +50,9 @@ class TestCall < Test::Unit::TestCase
o = nil
assert_nil(o&.x)
- assert_nothing_raised(NoMethodError) {o&.x = 6}
- assert_nothing_raised(NoMethodError) {o&.x *= 7}
+ assert_nothing_raised(NoMethodError) {o&.x = raise}
+ assert_nothing_raised(NoMethodError) {o&.x *= raise}
+ assert_nothing_raised(NoMethodError) {o&.x *= raise; nil}
end
def test_safe_call_evaluate_arguments_only_method_call_is_made
diff --git a/version.h b/version.h
index 26ea62e46e..6061bb15cf 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.7"
#define RUBY_RELEASE_DATE "2018-01-31"
-#define RUBY_PATCHLEVEL 396
+#define RUBY_PATCHLEVEL 397
#define RUBY_RELEASE_YEAR 2018
#define RUBY_RELEASE_MONTH 1