From 35b95ec2e2c1b377cb884c706fd0836328e5a90f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 5 Dec 2025 19:18:58 +0900 Subject: [Bug #21669] Add more void value expression check for `if` If the both branches are void, the `if`/`unless` is also void. --- test/ruby/test_syntax.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/ruby') 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 -- cgit v1.2.3