type errors

Stephen Weeks MLton@sourcelight.com
Thu, 14 Feb 2002 14:37:15 -0800


> A little verbose in places; what am I actually looking at here:
> 
> fun sum [] = 0
>   | sum (h::t) = t + (sum t)
...

You are seeing some leftover old error reporting.  I have checked in a
fix.  You now see:

z.sml:2.20-2.21 Error: unify: not an int
   t1: 'a1890 list
   t2: int
z.sml:2.20-2.21 Error: impossible use of overloaded var: operatorPlus
   ('a_75 list * 'a_75 list) -> 'a_75 list

I don't see a painless way to print "+" instead of "operatorPlus"
(other than to tranlsate the name back).  Maybe the right thing is to
keep the original name as "+", and do the renaming in the codegens.

> And, if I break foo.sml the other way, mlton prints an error message, but
> the compiler does not terminate (seems to go into an infinite
> (non-tail or allocating) loop, because eventually it dies with an out of
> memory error):
...
> fun sum [] = 0
>  | sum (h::t) = h + (sum h)

This was a problem with circular types, which were never handled
correctly (after all, MLton was only suppose to see correct programs
:-).  I have checed in a fix.  You now see:

z.sml:2.19-2.20 Error: unify: not an int
   t1: 'a1884 list
   t2: int
z.sml:2.19-2.20 Error: impossible use of overloaded var: operatorPlus
   (<recur> list * <recur> list) -> <recur> list
)