checker: check error for unknown type in anon fn field of struct (#13778)
parent
8c3687aa10
commit
0a78847782
|
@ -55,6 +55,16 @@ pub fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
|
||||||
field.type_pos)
|
field.type_pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
field_sym := c.table.sym(field.typ)
|
||||||
|
if field_sym.kind == .function {
|
||||||
|
fn_info := field_sym.info as ast.FnType
|
||||||
|
c.ensure_type_exists(fn_info.func.return_type, fn_info.func.return_type_pos) or {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for param in fn_info.func.params {
|
||||||
|
c.ensure_type_exists(param.typ, param.type_pos) or { return }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if sym.kind == .struct_ {
|
if sym.kind == .struct_ {
|
||||||
info := sym.info as ast.Struct
|
info := sym.info as ast.Struct
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
vlib/v/checker/tests/unknown_type_in_anon_fn.vv:5:10: error: unknown type `Another`
|
||||||
|
3 | struct Struc{
|
||||||
|
4 | mut:
|
||||||
|
5 | f fn (s Another, i int) ?
|
||||||
|
| ~~~~~~~
|
||||||
|
6 | }
|
||||||
|
7 |
|
|
@ -0,0 +1,8 @@
|
||||||
|
module main
|
||||||
|
|
||||||
|
struct Struc{
|
||||||
|
mut:
|
||||||
|
f fn (s Another, i int) ?
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
Loading…
Reference in New Issue