Loosen generic resolution.

This commit is contained in:
Christoffer Lerno
2025-09-24 00:12:58 +02:00
parent 3ccabd625c
commit c2abbe2e2f
3 changed files with 6 additions and 5 deletions

View File

@@ -858,9 +858,10 @@ INLINE bool sema_resolve_symbol_common(SemaContext *context, NameResolve *name_r
{
if (found->unit->module->generic_module == context->unit->module->generic_module)
{
RETURN_SEMA_ERROR_AT(name_resolve->span, "Generating a parameterized %s '%s' in the same module as the original "
"is not allowed, you need to place it outside of the '%s' module.",
str, found->name, context->unit->module->generic_module->name->module);
Decl *decl = module_find_symbol(context->unit->module->generic_module, found->name);
ASSERT(decl);
name_resolve->found = decl;
return true;
}
RETURN_SEMA_ERROR_AT(name_resolve->span, "This %s was matched as '%s%s' in module '%s%s', so parameterizing it further doesn't work.", str, found->name, found->unit->module->generic_suffix, found->unit->module->generic_module->name->module, found->unit->module->generic_suffix);
}

View File

@@ -10,7 +10,7 @@ struct Widget
List {any} children;
}
fn void Widget{Label}.draw(Widget* self) // #error: same module as the original is not allowed, you need to place it outside
fn void Widget{Label}.draw(Widget* self) // #error: The same method is generated by multiple instances
{
io::printfn("Hello Label");
}

View File

@@ -7,7 +7,7 @@ Aa {int} a;
module test1 {Type};
import test2;
alias Cc = Aa {Bb {Type}}; // #error:in the same module as the original is not allowed
alias Cc = Aa {Bb {Type}}; // #error: Generic resolution of this type has become deeply nested
struct Aa {Type a;}
module test2 {Type};