parser: check undefined variables in array inits (#10746)
parent
b222e4efae
commit
71e8237483
|
@ -0,0 +1,6 @@
|
|||
vlib/v/checker/tests/assign_expr_undefined_err_i.vv:2:23: error: undefined variable: `a`
|
||||
1 | fn main() {
|
||||
2 | mut a := []int{init: a}
|
||||
| ^
|
||||
3 | println(a)
|
||||
4 | }
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
mut a := []int{init: a}
|
||||
println(a)
|
||||
}
|
|
@ -30,6 +30,17 @@ fn (mut p Parser) check_undefined_variables(exprs []ast.Expr, val ast.Expr) ? {
|
|||
}
|
||||
}
|
||||
}
|
||||
ast.ArrayInit {
|
||||
if val.has_cap {
|
||||
p.check_undefined_variables(exprs, val.cap_expr) ?
|
||||
}
|
||||
if val.has_len {
|
||||
p.check_undefined_variables(exprs, val.len_expr) ?
|
||||
}
|
||||
if val.has_default {
|
||||
p.check_undefined_variables(exprs, val.default_expr) ?
|
||||
}
|
||||
}
|
||||
ast.CallExpr {
|
||||
p.check_undefined_variables(exprs, val.left) ?
|
||||
for arg in val.args {
|
||||
|
|
Loading…
Reference in New Issue