ruby-changes:47376
From: nagachika <ko1@a...>
Date: Fri, 4 Aug 2017 00:41:29 +0900 (JST)
Subject: [ruby-changes:47376] nagachika:r59492 (ruby_2_4): merge revision(s) 59202: [Backport #13690]
nagachika 2017-08-04 00:41:24 +0900 (Fri, 04 Aug 2017) New Revision: 59492 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59492 Log: merge revision(s) 59202: [Backport #13690] compile.c: disallow next in once * compile.c (iseq_compile_each0): turned dregx context in "once" into "guarded" type from "block" type, to disallow `next`, `break`, `redo` as well as outside "once". [ruby-core:81805] [Bug #13690] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/compile.c branches/ruby_2_4/test/ruby/test_exception.rb branches/ruby_2_4/test/ruby/test_syntax.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 59491) +++ ruby_2_4/version.h (revision 59492) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-08-04" -#define RUBY_PATCHLEVEL 165 +#define RUBY_PATCHLEVEL 166 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_4/test/ruby/test_syntax.rb =================================================================== --- ruby_2_4/test/ruby/test_syntax.rb (revision 59491) +++ ruby_2_4/test/ruby/test_syntax.rb (revision 59492) @@ -478,8 +478,16 @@ WARN https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_syntax.rb#L478 } end + def test_invalid_break + assert_syntax_error("def m; break; end", /Invalid break/) + assert_syntax_error('/#{break}/', /Invalid break/) + assert_syntax_error('/#{break}/o', /Invalid break/) + end + def test_invalid_next assert_syntax_error("def m; next; end", /Invalid next/) + assert_syntax_error('/#{next}/', /Invalid next/) + assert_syntax_error('/#{next}/o', /Invalid next/) end def test_lambda_with_space Index: ruby_2_4/test/ruby/test_exception.rb =================================================================== --- ruby_2_4/test/ruby/test_exception.rb (revision 59491) +++ ruby_2_4/test/ruby/test_exception.rb (revision 59492) @@ -1019,15 +1019,4 @@ $stderr = $stdout; raise "\x82\xa0"') do https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_exception.rb#L1019 } end; end - - def test_break_in_once - assert_separately([], "#{<<-"begin;"}\n#{<<~'end;'}") - begin; - obj = Object.new - def obj.try - /#{break}/o - end - assert_raise(LocalJumpError, /proc-closure/) {obj.try} - end; - end end Index: ruby_2_4/compile.c =================================================================== --- ruby_2_4/compile.c (revision 59491) +++ ruby_2_4/compile.c (revision 59492) @@ -29,6 +29,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/compile.c#L29 #undef RUBY_UNTYPED_DATA_WARNING #define RUBY_UNTYPED_DATA_WARNING 0 +#define ISEQ_TYPE_ONCE_GUARD ISEQ_TYPE_DEFINED_GUARD + #define FIXNUM_INC(n, i) ((n)+(INT2FIX(i)&~FIXNUM_FLAG)) #define FIXNUM_OR(n, i) ((n)|INT2FIX(i)) @@ -5773,7 +5775,8 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/compile.c#L5775 int ic_index = iseq->body->is_size++; NODE *dregx_node = NEW_NODE(NODE_DREGX, node->u1.value, node->u2.value, node->u3.value); NODE *block_node = NEW_NODE(NODE_SCOPE, 0, dregx_node, 0); - const rb_iseq_t * block_iseq = NEW_CHILD_ISEQ(block_node, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line); + const rb_iseq_t *block_iseq = NEW_CHILD_ISEQ(block_node, make_name_for_block(iseq), + ISEQ_TYPE_ONCE_GUARD, line); ADD_INSN2(ret, line, once, block_iseq, INT2FIX(ic_index)); Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 59491) +++ ruby_2_4 (revision 59492) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r59202 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/