From e7215d6278bb770c0a1656dae3b35a6ff4f28319 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 29 Jun 2017 04:01:30 +0000 Subject: 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_exception.rb | 11 ----------- test/ruby/test_syntax.rb | 8 ++++++++ 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index ecbf042e49..6955118de7 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1080,15 +1080,4 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| } 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 diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index b2bd688a77..c4d3d553be 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -478,8 +478,16 @@ WARN } 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 -- cgit v1.2.3