diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 562c082d06143d..40bfc7a0991c38 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -4375,7 +4375,14 @@ fn (mut c Checker) mark_as_referenced(mut node ast.Expr, as_interface bool) { node.obj.is_auto_heap = true } } - .sum_type, .interface_, .function {} + .sum_type, .interface_ {} + .function { + if type_sym.info is ast.FnType { + if type_sym.info.is_anon { + node.obj.is_auto_heap = true + } + } + } else { node.obj.is_auto_heap = true }