mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check undefined ident of struct (#9164)
This commit is contained in:
parent
f1c4e962f4
commit
1b47e2953d
@ -1063,6 +1063,9 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) (string, token.Position) {
|
||||
to_lock, pos = c.fail_if_immutable(expr.right)
|
||||
}
|
||||
ast.SelectorExpr {
|
||||
if expr.expr_type == 0 {
|
||||
return '', pos
|
||||
}
|
||||
// retrieve table.Field
|
||||
c.ensure_type_exists(expr.expr_type, expr.pos) or { return '', pos }
|
||||
mut typ_sym := c.table.get_final_type_symbol(c.unwrap_generic(expr.expr_type))
|
||||
|
7
vlib/v/checker/tests/undefined_ident_of_struct.out
Normal file
7
vlib/v/checker/tests/undefined_ident_of_struct.out
Normal file
@ -0,0 +1,7 @@
|
||||
vlib/v/checker/tests/undefined_ident_of_struct.vv:4:2: error: undefined ident: `f`
|
||||
2 |
|
||||
3 | fn get() {
|
||||
4 | f.a = 'test'
|
||||
| ^
|
||||
5 | }
|
||||
6 |
|
9
vlib/v/checker/tests/undefined_ident_of_struct.vv
Normal file
9
vlib/v/checker/tests/undefined_ident_of_struct.vv
Normal file
@ -0,0 +1,9 @@
|
||||
module main
|
||||
|
||||
fn get() {
|
||||
f.a = 'test'
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println('hello')
|
||||
}
|
Loading…
Reference in New Issue
Block a user