[m-rev.] for review: fix an inaccurate error message
Julien Fischer
jfischer at opturion.com
Sun Mar 30 15:14:44 AEDT 2025
For review by anyone.
I have attached a test case for this bug. I have not included it in
the diff because
I cannot make it work with any of the various invalid test directories we have.
(Rewriting it to use separate submodules has similar problems.) Suggestions
on where the test case should live would be appreciated.
---------------------------------------------
Fix an inaccurate error message.
When reporting that a module-qualified imported entity is undefined, we do a
check to see if the module is among those imported and, if not, include an
error message component saying that no module with that name has been imported.
For modules that are ancestors of the module being compiled we should not
emit this error message component since they are always implicitly imported.
compiler/module_qul.qual_errors.m:
Only emit a "No module named ... has been imported." error message component
if the module in question is *not* an ancestor of the module being compiled.
Julien.
diff --git a/compiler/module_qual.qual_errors.m
b/compiler/module_qual.qual_errors.m
index eb12e4c..f92976f 100644
--- a/compiler/module_qual.qual_errors.m
+++ b/compiler/module_qual.qual_errors.m
@@ -312,7 +312,11 @@ report_undefined_mq_id(Info, ErrorContext, Id,
IdType, ThisModuleName,
mq_info_get_imported_modules(Info, ImportedModuleNames),
AvailModuleNames =
[ThisModuleName | set_tree234.to_sorted_list(ImportedModuleNames)],
- module_name_matches_some(IdModuleName, AvailModuleNames) = no
+ module_name_matches_some(IdModuleName, AvailModuleNames) = no,
+
+ % Ancestors are always implicitly imported.
+ Ancestors = get_ancestors_set(ThisModuleName),
+ not set.contains(Ancestors, IdModuleName)
then
% This used to say "The module IdModuleName has not been imported.".
% However, a module with that name may not even exist, since it may be
-------------- next part --------------
A non-text attachment was scrubbed...
Name: undef_in_ancestor.m
Type: application/octet-stream
Size: 1247 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20250330/0736cea0/attachment.obj>
More information about the reviews
mailing list