diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-03 14:00:41 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-03 14:00:41 +0000 |
commit | 9b586688074a127cf51d162c3de6eb262488f132 (patch) | |
tree | 9ee2428553eb12a092fa722282d9ad42ea834f87 | |
parent | b08e0ade5baacbc7d4754e9f6afe8d09a3e00bc5 (diff) |
merge revision(s) 59169: [Backport #13678]
compile.c: toplevel return in argument
* compile.c (iseq_compile_each0): adjust the stack before return
in an evstr/argument (reported by Balazs <balazs@kutilovi.cz>)
to fix stack consistency error. [ruby-core:81761] [Bug #13678]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | compile.c | 1 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 4 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 5 insertions, 2 deletions
@@ -5479,6 +5479,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int poppe if (type == ISEQ_TYPE_TOP || type == ISEQ_TYPE_MAIN || ((type == ISEQ_TYPE_RESCUE || type == ISEQ_TYPE_ENSURE) && (parent_type == ISEQ_TYPE_TOP || parent_type == ISEQ_TYPE_MAIN))) { + ADD_ADJUST(ret, line, 0); ADD_INSN(ret, line, putnil); ADD_INSN(ret, line, leave); } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 4b9101bc7b..4f17f453a4 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -964,7 +964,7 @@ eom def test_return_toplevel feature4840 = '[ruby-core:36785] [Feature #4840]' - code = "#{<<~"begin;"}\n#{<<~"end;"}" + code = "#{<<~"begin;"}\n#{<<~'end;'}" begin; return; raise begin return; rescue SystemExit; exit false; end @@ -974,6 +974,8 @@ eom begin raise; rescue; return; end return false; raise return 1; raise + "#{return}" + raise((return; "should not raise")) end; all_assertions(feature4840) do |a| code.each_line do |s| @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-08-03" -#define RUBY_PATCHLEVEL 163 +#define RUBY_PATCHLEVEL 164 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 8 |