Updated tests and error message for failed generic lookups.

This commit is contained in:
Christoffer Lerno
2025-12-13 18:51:45 +01:00
parent b63886b879
commit 3577a2d6b8
4 changed files with 22 additions and 7 deletions

View File

@@ -849,7 +849,7 @@ INLINE bool sema_resolve_symbol_common(SemaContext *context, NameResolve *name_r
if (symbol) return name_resolve->found = symbol, true; if (symbol) return name_resolve->found = symbol, true;
} }
if (name_resolve->suppress_error) return name_resolve->found = NULL, true; if (name_resolve->suppress_error) return name_resolve->found = NULL, true;
RETURN_SEMA_ERROR_AT(name_resolve->span, "'%s' is defined in the generic module '%s', but no parameters where given.", found->name, found->unit->module->name->module); RETURN_SEMA_ERROR_AT(name_resolve->span, "'%s' is defined in the generic module '%s', did you forget the parameters '{ ... }'?", found->name, found->unit->module->name->module);
} }
else else
{ {

View File

@@ -1,5 +1,5 @@
module test; module test;
import std::collections::elastic_array;
fn void a() fn void a()
{ {
List {int} x; // #error: Did you mean the struct 'List' in module std::collections::list? If so please add List {int} x; // #error: Did you mean the struct 'List' in module std::collections::list? If so please add
@@ -17,15 +17,30 @@ fn void c()
fn void d() fn void d()
{ {
list::type_is_overaligned(); // #error: Did you mean the macro 'type_is_overaligned' in the generic module std::collections::list? If so, use 'type_is_overaligned{...}' instead list::type_is_overaligned(); // #error: Did you mean the macro 'std::collections::list::type_is_overaligned' in module std::collections::list? If so please add 'import std::collections::list'
}
fn void d2()
{
elastic_array::type_is_overaligned(); // #error: 'type_is_overaligned' is defined in the generic module 'std::collections::elastic_array', did you forget the parameters '{ ... }'?
} }
fn void e() fn void e()
{ {
List x; // #error: Did you mean the struct 'List' in the generic module std::collections::list? If so, use 'List{...}' List x; // #error: Did you mean the struct 'List' in module std::collections::list? If so please add 'import std::collections::list'
}
fn void f()
{
ElasticArray x; // #error: 'ElasticArray' is defined in the generic module 'std::collections::elastic_array', did you forget the parameters '{ ... }'?
}
fn void g()
{
(ElasticArray){}; // #error: 'ElasticArray' is defined in the generic module 'std::collections::elastic_array', did you forget the parameters '{ ... }'
} }
fn int main(String[] args) fn int main(String[] args)
{ {
return 0; return 0;
} }

View File

@@ -3,7 +3,7 @@ import std;
import abc; import abc;
fn void main() fn void main()
{ {
abc::test(); // #error: but no parameters where given abc::test(); // #error: 'test' is defined in the generic module 'abc', did you
} }
module abc{Type}; module abc{Type};
fn void test() {} fn void test() {}

View File

@@ -5,6 +5,6 @@ import std::collections::maybe;
fn void test() fn void test()
{ {
maybe::Maybe{float} f = (Maybe) {.value=6.6, .has_value=true}; maybe::Maybe{float} f = (Maybe) {.value=6.6, .has_value=true};
Maybe x; // #error: but no parameters where given Maybe x; // #error: 'Maybe' is defined in the generic module 'std::collections::maybe', did you forget the parameters '{ ... }'
} }