diff --git a/vlib/v/checker/struct.v b/vlib/v/checker/struct.v index e09ec820ba..320e306f3a 100644 --- a/vlib/v/checker/struct.v +++ b/vlib/v/checker/struct.v @@ -77,7 +77,7 @@ fn (mut c Checker) struct_decl(mut node ast.StructDecl) { if sym.kind == .function { if !field.typ.has_flag(.option) && !field.has_default_expr && field.attrs.filter(it.name == 'required').len == 0 { - error_msg := 'uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`)' + error_msg := 'uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`)' c.note(error_msg, field.pos) } } diff --git a/vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.out b/vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.out index d4a30b953c..0269535350 100644 --- a/vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.out +++ b/vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.vv:2:2: notice: uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`) +vlib/v/checker/tests/fn_check_for_matching_option_result_in_fields.vv:2:2: notice: uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`) 1 | struct Abc { 2 | f fn (voidptr) | ~~~~~~~~~~~~~~ diff --git a/vlib/v/checker/tests/generics_struct_init_err.out b/vlib/v/checker/tests/generics_struct_init_err.out index 7da3d9f920..9fab5e57bf 100644 --- a/vlib/v/checker/tests/generics_struct_init_err.out +++ b/vlib/v/checker/tests/generics_struct_init_err.out @@ -1,4 +1,4 @@ -vlib/v/checker/tests/generics_struct_init_err.vv:14:2: notice: uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`) +vlib/v/checker/tests/generics_struct_init_err.vv:14:2: notice: uninitialized `fn` struct fields are not allowed, since they can result in segfaults; use `?fn` or `[required]` or initialize the field with `=` (if you absolutely want to have unsafe function pointers, use `= unsafe { nil }`) 12 | 13 | struct FnHolder2[T] { 14 | func fn (int) int