diff --git a/releasenotes.md b/releasenotes.md index 01a13c1f7..42922a308 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -62,6 +62,7 @@ - Trying to slice an indexable type leads to misleading error message #2958 - Warn on use of visibility modifiers on methods. #2962 - Compiler crash using `??` with a `void?` macro #2973 +- Fix issue when extending a generic type with a method in another module. ## 0.7.9 Change list diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 067309ac0..e990998a9 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -5356,9 +5356,9 @@ FOUND:; if (decl->decl_kind != DECL_ERASED) vec_add(copied, decl); } - if (stage < ANALYSIS_METHODS_REGISTER) goto EXIT; FOREACH(Decl *, decl, copied) { + if (decl->unit->module->stage < ANALYSIS_METHODS_REGISTER) continue; if (decl->decl_kind != DECL_FUNC && decl->decl_kind != DECL_MACRO) continue; if (!decl->func_decl.type_parent) continue; SemaContext gen_context; @@ -5376,9 +5376,9 @@ FOUND:; } } } - if (stage < ANALYSIS_DECLS) goto EXIT; FOREACH(Decl *, decl, copied) { + if (decl->unit->module->stage < ANALYSIS_DECLS) continue; SemaContext context_gen; sema_context_init(&context_gen, decl->unit); DynamicScope empty = { .depth = 0 }; @@ -5392,10 +5392,10 @@ FOUND:; } sema_context_destroy(&context_gen); } - if (stage < ANALYSIS_FUNCTIONS) goto EXIT; if (compiler.context.errors_found) return poisoned_decl; FOREACH(Decl *, decl, copied) { + if (decl->unit->module->stage < ANALYSIS_FUNCTIONS) continue; SemaContext context_gen; switch (decl->decl_kind) { @@ -5408,10 +5408,10 @@ FOUND:; break; } } - if (stage < ANALYSIS_INTERFACE) goto EXIT; if (compiler.context.errors_found) return poisoned_decl; FOREACH(Decl *, decl, copied) { + if (decl->unit->module->stage < ANALYSIS_INTERFACE) continue; SemaContext context_gen; switch (decl->decl_kind) { @@ -5431,7 +5431,6 @@ FOUND:; sema_context_destroy(&context_gen); } } -EXIT:; if (compiler.context.errors_found) return poisoned_decl; } Decl *symbol = sema_find_generic_instance(context, module, generic, instance, alias->name); diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index f0ad33037..8d01b6f24 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -11045,6 +11045,7 @@ static inline bool sema_expr_analyse_lambda(SemaContext *context, Type *target_t } else { + decl->resolve_status = RESOLVE_DONE; SemaContext lambda_context; sema_context_init(&lambda_context, context->unit); if (sema_analyse_function_body(&lambda_context, decl)) diff --git a/src/compiler/sema_stmts.c b/src/compiler/sema_stmts.c index a5b2b2369..084e70ec4 100644 --- a/src/compiler/sema_stmts.c +++ b/src/compiler/sema_stmts.c @@ -3360,6 +3360,7 @@ bool sema_analyse_function_body(SemaContext *context, Decl *func) { // Stop if it's already poisoned. if (!decl_ok(func)) return false; + ASSERT_SPAN(func, func->resolve_status == RESOLVE_DONE); if (func->is_body_checked) return true; func->is_body_checked = true; context->generic_instance = func->is_templated ? declptr(func->instance_id) : NULL;