summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-17 21:36:41 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-17 21:44:06 +0900
commit01b3a3804334be19d013526d3edde2b84399ae43 (patch)
tree258e4a7564db7065d2f8f3d9e13a75c4da4843a3 /test
parent09a846085c2e675aa8397e9351c52d68215d7fa4 (diff)
Fix wrong "void value expression" error
* parse.y (value_expr_check): if either of `then` or `else` statements is not a void value expression, the whole `if` is not also a void value expression. [Bug #15932]
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_syntax.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 4e8ffe56fb..541170ff8f 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1388,6 +1388,12 @@ eom
assert_syntax_error('a|>-b', /unexpected '-'/)
end
+ def test_value_expr_in_condition
+ mesg = /void value expression/
+ assert_syntax_error("tap {a = (true ? next : break)}", mesg)
+ assert_valid_syntax("tap {a = (true ? true : break)}")
+ end
+
private
def not_label(x) @result = x; @not_label ||= nil end