parser: make `v := f(v)' an undefined variable error (#8634)
parent
03d5bfbc95
commit
8ae23cd89e
|
@ -0,0 +1,7 @@
|
|||
vlib/v/checker/tests/assign_expr_undefined_err_h.vv:6:9: error: undefined variable: `n`
|
||||
4 |
|
||||
5 | fn main() {
|
||||
6 | n := f(n)
|
||||
| ^
|
||||
7 | println(n)
|
||||
8 | }
|
|
@ -0,0 +1,8 @@
|
|||
fn f(i int) int {
|
||||
return i
|
||||
}
|
||||
|
||||
fn main() {
|
||||
n := f(n)
|
||||
println(n)
|
||||
}
|
|
@ -25,6 +25,9 @@ fn (mut p Parser) check_undefined_variables(exprs []ast.Expr, val ast.Expr) ? {
|
|||
}
|
||||
ast.CallExpr {
|
||||
p.check_undefined_variables(exprs, val.left) ?
|
||||
for arg in val.args {
|
||||
p.check_undefined_variables(exprs, arg.expr) ?
|
||||
}
|
||||
}
|
||||
ast.InfixExpr {
|
||||
p.check_undefined_variables(exprs, val.left) ?
|
||||
|
|
Loading…
Reference in New Issue