Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jun 25, 2023
1 parent ec35d76 commit 100f441
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vlib/v/checker/struct.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
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 {
c.expected_type = field.typ
Expand Down

0 comments on commit 100f441

Please sign in to comment.