mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: make `v := f(v)' an undefined variable error (#8634)
This commit is contained in:
parent
03d5bfbc95
commit
8ae23cd89e
7
vlib/v/checker/tests/assign_expr_undefined_err_h.out
Normal file
7
vlib/v/checker/tests/assign_expr_undefined_err_h.out
Normal file
@ -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 | }
|
8
vlib/v/checker/tests/assign_expr_undefined_err_h.vv
Normal file
8
vlib/v/checker/tests/assign_expr_undefined_err_h.vv
Normal file
@ -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
Block a user