diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 7292bd696..5645fe5eb 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -10938,6 +10938,12 @@ static inline bool sema_expr_analyse_lambda(SemaContext *context, Type *target_t // so we'll declare it as weak and externally visible. unit_register_external_symbol(context, decl); + if (context->generic_instance) + { + decl->is_templated = true; + decl->instance_id = declid(context->generic_instance); + } + // Before function analysis, lambda evaluation is deferred if (unit->module->stage < ANALYSIS_FUNCTIONS) { @@ -10947,11 +10953,6 @@ static inline bool sema_expr_analyse_lambda(SemaContext *context, Type *target_t decl->var.is_read = true; } decl_flatten(decl)->is_external_visible = true; - if (context->generic_instance) - { - decl->is_templated = true; - decl->instance_id = declid(context->generic_instance); - } vec_add(unit->module->lambdas_to_evaluate, decl); } else