mirror of
https://github.com/vlang/v.git
synced 2025-09-17 11:26:17 -04:00
parent
582f7be2e1
commit
e2334d8b62
@ -666,7 +666,17 @@ fn (mut p Parser) infix_expr(left ast.Expr) ast.Expr {
|
|||||||
p.inside_in_array = true
|
p.inside_in_array = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
right_op_pos := p.tok.pos()
|
||||||
right = p.expr(precedence)
|
right = p.expr(precedence)
|
||||||
|
if op in [.plus, .minus, .mul, .div, .mod, .lt, .eq] && mut right is ast.PrefixExpr {
|
||||||
|
mut right_expr := right.right
|
||||||
|
for mut right_expr is ast.ParExpr {
|
||||||
|
right_expr = right_expr.expr
|
||||||
|
}
|
||||||
|
if right.op in [.plus, .minus, .mul, .div, .mod, .lt, .eq] && right_expr.is_pure_literal() {
|
||||||
|
p.error_with_pos('invalid expression: unexpected token `${op}`', right_op_pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
if is_key_in {
|
if is_key_in {
|
||||||
p.inside_in_array = false
|
p.inside_in_array = false
|
||||||
}
|
}
|
||||||
|
3
vlib/v/parser/tests/prefix_err_1.out
Normal file
3
vlib/v/parser/tests/prefix_err_1.out
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
vlib/v/parser/tests/prefix_err_1.vv:1:9: error: invalid expression: unexpected token `-`
|
||||||
|
1 | _ = 5 - - -5
|
||||||
|
| ^
|
1
vlib/v/parser/tests/prefix_err_1.vv
Normal file
1
vlib/v/parser/tests/prefix_err_1.vv
Normal file
@ -0,0 +1 @@
|
|||||||
|
_ = 5 - - -5
|
3
vlib/v/parser/tests/prefix_err_2.out
Normal file
3
vlib/v/parser/tests/prefix_err_2.out
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
vlib/v/parser/tests/prefix_err_2.vv:1:9: error: invalid expression: unexpected token `-`
|
||||||
|
1 | _ = 5 - - (((-5)))
|
||||||
|
| ^
|
1
vlib/v/parser/tests/prefix_err_2.vv
Normal file
1
vlib/v/parser/tests/prefix_err_2.vv
Normal file
@ -0,0 +1 @@
|
|||||||
|
_ = 5 - - (((-5)))
|
Loading…
x
Reference in New Issue
Block a user