Mercury Bugs - mercury
View Issue Details
0000521mercuryBugpublic2020-09-29 17:232022-01-25 01:24
Reporterdirkz 
Assigned Tozs 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformMercury 20.06OSmacOS CatalinaOS Version10.15.7
Product Version 
Target VersionFixed in Version 
Summary0000521: Missing error message about an 'undefined type'; misleading error message instead
DescriptionThe compiler should clearly complain about an 'undefined type'.

Expected error message:
thing_def.m:17 error: undefined type `list'/1.

Actual error message:
main.m:033: In clause for predicate `get_wrapped_things'/1:
main.m:033: in argument 1 of functor `list_wrapper/1':
main.m:033: type error in unification of argument
main.m:033: and constant `get_things'.
main.m:033: argument has type `list.list(thing_def.thing)',
main.m:033: constant `get_things' has type `list(thing_def.thing)'.
For more information, recompile with `-E'.
Steps To Reproducemmc --make main
Additional InformationAttached example:

Module thing_def.m declares this function without importing the list module:

:- func get_things = list(thing).

Not importing the list module is the actual problem. But the compiler does not complain about the missing import. Instead it issues a misleading error message.
TagsNo tags attached.
Attached Filestgz example.tgz (434) 2020-09-29 17:23
https://bugs.mercurylang.org/file_download.php?file_id=307&type=bug

Notes
(0001108)
zs   
2020-10-08 16:10   
I just added code to compiler to complain about the missing import. It should
be in the next ROTD. You still get the misleading error message, but you
also get a non-misleading pointer to where the error is.

The error should really be diagnosed when the compiler makes the interface file
for the module with the missing import. The compiler has had an option named
--print-errors-warnings-when-generating-interface for a while now which does
exactly that, but for now, it is not turned on by default, because it is part
of a bigger set of changes that are not complete yet. However, if you are willing to live with an experimental-for-now feature, you can enable it manually.
(0001111)
dirkz   
2020-10-12 05:15   
Thank you for fixing the error message.

I just performed a successful test with rotd-2020-10-09 on MacOS High Sierra 10.13.6.
(0001159)
zs   
2022-01-25 01:24   
The compiler has been diagnosing such errors when making interface files
for some time now.

Issue History
2020-09-29 17:23dirkzNew Issue
2020-09-29 17:23dirkzFile Added: example.tgz
2020-10-08 16:04zsAssigned To => zs
2020-10-08 16:04zsStatusnew => assigned
2020-10-08 16:10zsNote Added: 0001108
2020-10-12 05:15dirkzNote Added: 0001111
2022-01-25 01:24zsStatusassigned => resolved
2022-01-25 01:24zsResolutionopen => fixed
2022-01-25 01:24zsNote Added: 0001159