[m-users.] Use of length() as function giving unexpected (to me) error

Sean Charles (emacstheviking) objitsu at gmail.com
Sat Oct 30 07:57:35 AEDT 2021


Given that Args and PStrings are lists of different things, I just sought to compare their length:

args_to_pstrings(Args, [], _, PStrings, !T),
( if length(Args) = length(PStrings) then …

translate.m:174: In clause for predicate `translate_call'/4:
translate.m:174:   error: ambiguous overloading causes type ambiguity.
translate.m:174:   Possible type assignments include:
translate.m:174:   V_27: `int' or `(pred int)'
translate.m:174:   You will need to add an explicit type qualification to
translate.m:174:   resolve the type ambiguity. The way to add an explicit type
translate.m:174:   qualification is to use "with_type". For details see the
translate.m:174:   "Explicit type qualification" sub-section of the
translate.m:174:   "Data-terms" section of the "Syntax" chapter of the Mercury
translate.m:174:   language reference manual.
** Error making `Mercury/opts/translate.opt’.

changing to the predicate form removes the error,

list.length(Args, L1),
list.length(PStrings, L2),
( if L1 = L2 then …

Compiles fine. I know that from the error message it seems that I have somehow produced a curried call ?! I am also using the `int` module as well. Just seeking some explanation!

Thanks
Sean



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20211029/19512c8b/attachment.html>


More information about the users mailing list