parser: check undefined variable of assign_expr
parent
f3c5f36317
commit
1e504fb388
|
@ -0,0 +1,6 @@
|
|||
vlib/v/checker/tests/assign_expr_undefined_err_e.v:2:11: error: undefined variable: `a`
|
||||
1 | fn main() {
|
||||
2 | a, b := -a, -b
|
||||
| ^
|
||||
3 | println(s)
|
||||
4 | }
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
a, b := -a, -b
|
||||
println(s)
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
vlib/v/checker/tests/assign_expr_undefined_err_f.v:2:12: error: undefined variable: `a`
|
||||
1 | fn main() {
|
||||
2 | a, b := (-a + 1), 1
|
||||
| ^
|
||||
3 | println('$a, $b')
|
||||
4 | }
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
a, b := (-a + 1), 1
|
||||
println('$a, $b')
|
||||
}
|
|
@ -22,6 +22,15 @@ fn (mut p Parser) check_undefined_variables(idents []ast.Ident, expr ast.Expr) {
|
|||
p.check_undefined_variables(idents, it.left)
|
||||
p.check_undefined_variables(idents, it.right)
|
||||
}
|
||||
ast.ParExpr {
|
||||
p.check_undefined_variables(idents, it.expr)
|
||||
}
|
||||
ast.PostfixExpr {
|
||||
p.check_undefined_variables(idents, it.expr)
|
||||
}
|
||||
ast.PrefixExpr {
|
||||
p.check_undefined_variables(idents, it.right)
|
||||
}
|
||||
ast.StringInterLiteral {
|
||||
for expr_ in it.exprs {
|
||||
p.check_undefined_variables(idents, expr_)
|
||||
|
|
Loading…
Reference in New Issue