Fix error message when not finding a particular function

This commit is contained in:
Christoffer Lerno
2024-09-16 22:43:30 +02:00
parent 81f1930349
commit 1181edc48e
2 changed files with 16 additions and 3 deletions

View File

@@ -29,6 +29,7 @@
- Fix bugs in "trap-on-wrap" #1434.
- Bug with casting anyfault to error.
- Lambda / function type would accidentally be processed as a method.
- Fix error message when not finding a particular function.
### Stdlib changes
- Additional init functions for hashmap.

View File

@@ -687,10 +687,22 @@ INLINE bool sema_resolve_symbol_common(SemaContext *context, NameResolve *name_r
{
if (matches_subpath(module->name, name_resolve->path))
{
module_with_path = module;
break;
FOREACH(Decl *, import, context->unit->imports)
{
Module *mod = module;
while (mod)
{
if (import->import.module == mod)
{
module_with_path = module;
goto MOD_FOUND;
}
mod = mod->parent_module;
}
}
}
}
MOD_FOUND:
if (!module_with_path)
{
FOREACH(Module *, module, compiler.context.generic_module_list)
@@ -707,7 +719,7 @@ INLINE bool sema_resolve_symbol_common(SemaContext *context, NameResolve *name_r
{
RETURN_SEMA_ERROR(name_resolve, "'%s' could not be found in %s.", name_resolve->symbol, module_with_path->name->module);
}
RETURN_SEMA_ERROR(name_resolve->path, "Unknown module '%.*s', did you type it right?", name_resolve->path->len, name_resolve->path->module);
RETURN_SEMA_ERROR(name_resolve->path, "No '%.*s' module was imported, did you type it right?", name_resolve->path->len, name_resolve->path->module);
}
}
else