1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
Felipe Pena 2023-06-25 15:54:48 -03:00
parent ec35d76574
commit 100f441e3f

View File

@ -135,6 +135,13 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) {
c.error('cannot use Result type as map value type', field.type_pos) c.error('cannot use Result type as map value type', field.type_pos)
} }
} }
if sym.kind == .function {
fn_info := sym.info as ast.FnType
if !field.typ.has_flag(.option) && fn_info.is_anon {
c.warn('direct function declaration is not recommended, use Option instead (?fn ...)',
field.type_pos)
}
}
if field.has_default_expr { if field.has_default_expr {
c.expected_type = field.typ c.expected_type = field.typ