From 100f441e3f865d9863dd86b5369957be3eebfd1d Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 25 Jun 2023 15:54:48 -0300 Subject: [PATCH] initial --- vlib/v/checker/struct.v | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/vlib/v/checker/struct.v b/vlib/v/checker/struct.v index 25d5893daed60a..9af6abea9f0040 100644 --- a/vlib/v/checker/struct.v +++ b/vlib/v/checker/struct.v @@ -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