diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-29 01:58:07 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-29 03:14:17 +0900 |
| commit | eaa0fbf9b956fa25e73c3d55e2eba8887324e233 (patch) | |
| tree | 0b07d87c32f8be0cd18401d13c6ee3897aeef948 /test/ruby | |
| parent | 5a376f0f71e8ecc8a6cc0b9f35e63a8367275988 (diff) | |
Fix `retry` in nested `rescue` blocks
Restore `rescue`-context from the outer context.
`retry` targets the next outer block except for between `rescue` and
`else` or `ensure`, otherwise, if there is no enclosing block, it
should be syntax error.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_ast.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb index 76fd2b3783..f2c746aafa 100644 --- a/test/ruby/test_ast.rb +++ b/test/ruby/test_ast.rb @@ -283,6 +283,27 @@ class TestAst < Test::Unit::TestCase assert_parse("begin rescue; ensure; defined? retry; end") assert_parse("END {defined? retry}") assert_parse("begin rescue; END {defined? retry}; end") + + assert_parse("#{<<-"begin;"}\n#{<<-'end;'}") + begin; + def foo + begin + yield + rescue StandardError => e + begin + puts "hi" + retry + rescue + retry unless e + raise e + else + retry + ensure + retry + end + end + end + end; end def test_invalid_yield |
