1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: check undefined ident in reference selector (#14949)

This commit is contained in:
yuyi 2022-07-05 21:29:54 +08:00 committed by GitHub
parent 8b8667dd9a
commit 56d62a6e6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 0 deletions

View File

@ -1124,6 +1124,7 @@ pub fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type {
// This means that the field has an undefined type.
// This error was handled before.
// c.error('`void` type has no fields', node.pos)
node.expr_type = ast.void_type
return ast.void_type
}
node.expr_type = typ

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/undefined_ident_in_ref_selector.vv:6:10: error: undefined ident: `line`
4 |
5 | fn read() int {
6 | return &line.len
| ~~~~
7 | }

View File

@ -0,0 +1,7 @@
module main
fn main() {}
fn read() int {
return &line.len
}