From 84a52aea8cb20468c3528ac8f570a6370377f05f Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Fri, 15 Mar 2024 11:26:23 +0100 Subject: [PATCH] checker: fix undefined reference to interface struct field regression (after #21025) (#21030) --- vlib/v/checker/struct.v | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/vlib/v/checker/struct.v b/vlib/v/checker/struct.v index e3f73d965b72c1..0dd9b208510191 100644 --- a/vlib/v/checker/struct.v +++ b/vlib/v/checker/struct.v @@ -654,10 +654,11 @@ or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.', } } if exp_type_sym.kind == .interface_ { - if got_type_sym.kind != .interface_ && !c.inside_unsafe - && !got_type.is_any_kind_of_pointer() - && c.type_implements(got_type, exp_type, init_field.pos) { - c.mark_as_referenced(mut &init_field.expr, true) + if c.type_implements(got_type, exp_type, init_field.pos) { + if !c.inside_unsafe && got_type_sym.kind != .interface_ + && !got_type.is_any_kind_of_pointer() { + c.mark_as_referenced(mut &init_field.expr, true) + } } } else if got_type != ast.void_type && got_type_sym.kind != .placeholder && !exp_type.has_flag(.generic) {