parser: check assign_stmt of undefined variable (#8366)

pull/8376/head
yuyi 2021-01-27 20:52:10 +08:00 committed by GitHub
parent 1f4e8254b9
commit 7a5722c885
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,5 @@
vlib/v/checker/tests/assign_expr_undefined_err_g.vv:2:14: error: undefined variable: `file`
1 | fn main() {
2 | mut file := file.open_file('bees.pdf', 'rw', 0o666)
| ~~~~
3 | }

View File

@ -0,0 +1,3 @@
fn main() {
mut file := file.open_file('bees.pdf', 'rw', 0o666)
}

View File

@ -23,6 +23,9 @@ fn (mut p Parser) check_undefined_variables(exprs []ast.Expr, val ast.Expr) ? {
}
}
}
ast.CallExpr {
p.check_undefined_variables(exprs, val.left) ?
}
ast.InfixExpr {
p.check_undefined_variables(exprs, val.left) ?
p.check_undefined_variables(exprs, val.right) ?