[前][次][番号順一覧][スレッド一覧]

ruby-changes:47055

From: nobu <ko1@a...>
Date: Sun, 25 Jun 2017 14:10:54 +0900 (JST)
Subject: [ruby-changes:47055] nobu:r59169 (trunk): compile.c: toplevel return in argument

nobu	2017-06-25 14:10:48 +0900 (Sun, 25 Jun 2017)

  New Revision: 59169

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59169

  Log:
    compile.c: toplevel return in argument
    
    * compile.c (iseq_compile_each0): adjust the stack before return
      in an evstr/argument (reported by Balazs <balazs@k...>)
      to fix stack consistency error.  [ruby-core:81761] [Bug #13678]

  Modified files:
    trunk/compile.c
    trunk/test/ruby/test_syntax.rb
Index: compile.c
===================================================================
--- compile.c	(revision 59168)
+++ compile.c	(revision 59169)
@@ -5590,6 +5590,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L5590
 	    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);
 	    }
Index: test/ruby/test_syntax.rb
===================================================================
--- test/ruby/test_syntax.rb	(revision 59168)
+++ test/ruby/test_syntax.rb	(revision 59169)
@@ -964,7 +964,7 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L964
 
   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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L974
       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|

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]