diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-10-02 07:56:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-02 07:56:28 -0700 |
commit | ef697388becedf36966a2edcdcf88baca342b9e2 (patch) | |
tree | 816a19ad728f795d71402db947386e7e9dfb6226 /test/ruby | |
parent | 9759e3c9f09ec442b2aa0d0cc299ac791e516a01 (diff) | |
download | ruby-ef697388becedf36966a2edcdcf88baca342b9e2.tar.gz |
Treat return in block in class/module as LocalJumpError (#2511)
return directly in class/module is an error, so return in
proc in class/module should also be an error. I believe the
previous behavior was an unintentional oversight during the
addition of top-level return in 2.4.
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_syntax.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index a64d25845a..80bff868f6 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1272,6 +1272,10 @@ eom assert_warn(/argument of top-level return is ignored/) {eval("return 1")} end + def test_return_in_proc_in_class + assert_in_out_err(['-e', 'class TestSyntax; proc{ return }.call; end'], "", [], /^-e:1:.*unexpected return \(LocalJumpError\)/) + end + def test_syntax_error_in_rescue bug12613 = '[ruby-core:76531] [Bug #12613]' assert_syntax_error("#{<<-"begin;"}\n#{<<-"end;"}", /Invalid retry/, bug12613) |