mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: check undefined variable of assign_expr
This commit is contained in:
parent
f3c5f36317
commit
1e504fb388
6
vlib/v/checker/tests/assign_expr_undefined_err_e.out
Normal file
6
vlib/v/checker/tests/assign_expr_undefined_err_e.out
Normal file
@ -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 | }
|
4
vlib/v/checker/tests/assign_expr_undefined_err_e.vv
Normal file
4
vlib/v/checker/tests/assign_expr_undefined_err_e.vv
Normal file
@ -0,0 +1,4 @@
|
||||
fn main() {
|
||||
a, b := -a, -b
|
||||
println(s)
|
||||
}
|
6
vlib/v/checker/tests/assign_expr_undefined_err_f.out
Normal file
6
vlib/v/checker/tests/assign_expr_undefined_err_f.out
Normal file
@ -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 | }
|
4
vlib/v/checker/tests/assign_expr_undefined_err_f.vv
Normal file
4
vlib/v/checker/tests/assign_expr_undefined_err_f.vv
Normal file
@ -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
Block a user