mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: check undefined variable in if guard (#15882)
This commit is contained in:
parent
8623186d31
commit
959eeaf1f3
@ -200,6 +200,9 @@ fn (mut p Parser) check_undefined_variables_by_names(names []string, val ast.Exp
|
||||
ast.PrefixExpr {
|
||||
p.check_undefined_variables_by_names(names, val.right)?
|
||||
}
|
||||
ast.SelectorExpr {
|
||||
p.check_undefined_variables_by_names(names, val.expr)?
|
||||
}
|
||||
ast.StringInterLiteral {
|
||||
for expr_ in val.exprs {
|
||||
p.check_undefined_variables_by_names(names, expr_)?
|
||||
|
7
vlib/v/parser/tests/if_guard_undefined_variable_err.out
Normal file
7
vlib/v/parser/tests/if_guard_undefined_variable_err.out
Normal file
@ -0,0 +1,7 @@
|
||||
vlib/v/parser/tests/if_guard_undefined_variable_err.vv:4:10: error: undefined variable: `f`
|
||||
2 |
|
||||
3 | fn main() {
|
||||
4 | if f := f.g.x() {
|
||||
| ^
|
||||
5 | }
|
||||
6 | }
|
6
vlib/v/parser/tests/if_guard_undefined_variable_err.vv
Normal file
6
vlib/v/parser/tests/if_guard_undefined_variable_err.vv
Normal file
@ -0,0 +1,6 @@
|
||||
module main
|
||||
|
||||
fn main() {
|
||||
if f := f.g.x() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user