Fix wrong "void value expression" error
* parse.y (value_expr_check): `then` or `else` only `if` is not a void value expression, as the counterpart is evaluated as `nil`. [Bug #15932]
This commit is contained in:
parent
01b3a38043
commit
c8e9e0b74b
6
parse.y
6
parse.y
@ -10552,12 +10552,10 @@ value_expr_check(struct parser_params *p, NODE *node)
|
|||||||
case NODE_IF:
|
case NODE_IF:
|
||||||
case NODE_UNLESS:
|
case NODE_UNLESS:
|
||||||
if (!node->nd_body) {
|
if (!node->nd_body) {
|
||||||
node = node->nd_else;
|
return NULL;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else if (!node->nd_else) {
|
else if (!node->nd_else) {
|
||||||
node = node->nd_body;
|
return NULL;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
vn = value_expr_check(p, node->nd_body);
|
vn = value_expr_check(p, node->nd_body);
|
||||||
if (!vn) return NULL;
|
if (!vn) return NULL;
|
||||||
|
@ -1392,6 +1392,8 @@ eom
|
|||||||
mesg = /void value expression/
|
mesg = /void value expression/
|
||||||
assert_syntax_error("tap {a = (true ? next : break)}", mesg)
|
assert_syntax_error("tap {a = (true ? next : break)}", mesg)
|
||||||
assert_valid_syntax("tap {a = (true ? true : break)}")
|
assert_valid_syntax("tap {a = (true ? true : break)}")
|
||||||
|
assert_valid_syntax("tap {a = (break if false)}")
|
||||||
|
assert_valid_syntax("tap {a = (break unless true)}")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
Loading…
x
Reference in New Issue
Block a user