diff --git a/releasenotes.md b/releasenotes.md index fd1ef448a..be215dc87 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -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. diff --git a/src/compiler/sema_name_resolution.c b/src/compiler/sema_name_resolution.c index dfd3ed4e5..a2d23c3ad 100644 --- a/src/compiler/sema_name_resolution.c +++ b/src/compiler/sema_name_resolution.c @@ -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