diff --git a/vlib/v/checker/tests/assign_expr_undefined_err_g.out b/vlib/v/checker/tests/assign_expr_undefined_err_g.out new file mode 100644 index 0000000000..277bbaffac --- /dev/null +++ b/vlib/v/checker/tests/assign_expr_undefined_err_g.out @@ -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 | } diff --git a/vlib/v/checker/tests/assign_expr_undefined_err_g.vv b/vlib/v/checker/tests/assign_expr_undefined_err_g.vv new file mode 100644 index 0000000000..b589a7803b --- /dev/null +++ b/vlib/v/checker/tests/assign_expr_undefined_err_g.vv @@ -0,0 +1,3 @@ +fn main() { + mut file := file.open_file('bees.pdf', 'rw', 0o666) +} diff --git a/vlib/v/parser/assign.v b/vlib/v/parser/assign.v index 41499df4e5..69cd4ae837 100644 --- a/vlib/v/parser/assign.v +++ b/vlib/v/parser/assign.v @@ -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) ?