diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-05 19:18:58 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-02-04 13:28:33 +0900 |
| commit | 35b95ec2e2c1b377cb884c706fd0836328e5a90f (patch) | |
| tree | afc8fcd25ea12bfa1e2fda707c91f359e9f1b8da /test | |
| parent | 932ce048feb9f26bcd9e8dc93ada4d2a407ace1f (diff) | |
[Bug #21669] Add more void value expression check for `if`
If the both branches are void, the `if`/`unless` is also void.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ruby/test_syntax.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 3638d83e2b..a64591ecec 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -2021,6 +2021,15 @@ eom assert_valid_syntax("tap {a = (true ? true : break)}") assert_valid_syntax("tap {a = (break if false)}") assert_valid_syntax("tap {a = (break unless true)}") + + assert_syntax_error("#{<<~"{#"}\n#{<<~'};'}", /void value expression/, nil, "#{BUG_21669} 1.4") + {# + x = if rand < 0.5 + return + else + return + end + }; end def test_value_expr_in_singleton |
