diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2025-12-05 19:01:21 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-02-04 13:28:33 +0900 |
| commit | 932ce048feb9f26bcd9e8dc93ada4d2a407ace1f (patch) | |
| tree | fca6fc1a0d75d07f1dc07b2d8aa2037ff89d9f03 /test | |
| parent | 4f360107387c47bfd82e7010b8eb7393575d4d76 (diff) | |
[Bug #21669] Implement void value expression check for `case`/`when`
If the all `when` and `else` branches are void, the `case` is also
void.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ruby/test_syntax.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 9a14375056..3638d83e2b 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -2053,6 +2053,30 @@ eom }; end + def test_value_expr_in_case + assert_syntax_error("#{<<~"{#"}\n#{<<~'};'}", /void value expression/, nil, "#{BUG_21669} 1.3") + {# + x = + case a + when 1; return + when 2; return + else return + end + }; + end + + def test_value_expr_in_case2 + assert_syntax_error("#{<<~"{#"}\n#{<<~'};'}", /void value expression/, nil, "#{BUG_21669} 1.3") + {# + x = + case + when 1; return + when 2; return + 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") |
