You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:- import_module list, int.
:- type myintlist ---> list(int).
:- func MyMerge(myintlist, myintlist) = myintlist.
MyMerge(A, B) = A ++ B.
The compiler says:
hello.m:013: In clause for function `'/3:
hello.m:013: in function result term of clause head:
hello.m:013: type error in unification of variable `HeadVar__4'
hello.m:013: and functor `++/2'.
hello.m:013: variable `HeadVar__4' has type `hello.myintlist',
hello.m:013: functor `++/2' has type
hello.m:013: `(list.list(T) ++ list.list(T)): list.list(T)'.
which is horrific! (and even worse for set). It gives no insight whatsoever.
and, perhaps, experienced Mercury coder won't do this mistake — but newbies likely will.
My point is that it'd be easy to check if a user-defined data constructor name clashes with a type/type constructor name in scope, and issue a warning or suggestion for such a type definition. It'd help avoid the error.
The text was updated successfully, but these errors were encountered:
It's easy to make an error like this:
The compiler says:
which is horrific! (and even worse for
set
). It gives no insight whatsoever.Corrected code is:
and, perhaps, experienced Mercury coder won't do this mistake — but newbies likely will.
My point is that it'd be easy to check if a user-defined data constructor name clashes with a type/type constructor name in scope, and issue a warning or suggestion for such a type definition. It'd help avoid the error.
The text was updated successfully, but these errors were encountered: