diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-05 18:52:34 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-02-04 13:28:33 +0900 |
| commit | c8b2a453d0fe099064e095d165ce38ee8c3eef38 (patch) | |
| tree | 6bd475dde36521ac60058bb49b9a37effdd130d1 /test | |
| parent | 995c80bcd8509f59374506c04b60d94128cc2699 (diff) | |
[Bug #21669] Fix void value expression check for `rescue`
If any `rescue` node is non-void, the enclosing block is also
non-void.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ruby/test_syntax.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 5065a1db33..79e373ea66 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -2013,6 +2013,8 @@ eom assert_equal(1, b.new.foo(1), bug21256) end + BUG_21669 = '[Bug #21669]' + def test_value_expr_in_condition mesg = /void value expression/ assert_syntax_error("tap {a = (true ? next : break)}", mesg) @@ -2026,6 +2028,20 @@ eom assert_syntax_error("class << (return); end", mesg) end + def test_value_expr_in_rescue + assert_valid_syntax("#{<<~"{#"}\n#{<<~'};'}", "#{BUG_21669} 1.1") + {# + x = begin + raise + return + rescue + "OK" + else + return + end + }; + end + def test_tautological_condition assert_valid_syntax("def f() return if false and invalid; nil end") assert_valid_syntax("def f() return unless true or invalid; nil end") |
