type errors
Matthew Fluet
fluet@cs.cornell.edu
Thu, 14 Feb 2002 09:20:19 -0500 (EST)
----------------------------
revision 1.39
date: 2002/02/13 21:41:32; author: sweeks; state: Exp; lines: +1 -1
Improvements to error reporting for type errors. This involved propagating
source position information into CoreML and passing it to the unify routine,
which actually generates the errors.
Very cool! And even useful! Although I'm going to miss the tercity of
"unify Con" ;)
A little verbose in places; what am I actually looking at here:
[fluet@lennon foo]$ cat foo.sml
fun sum [] = 0
| sum (h::t) = t + (sum t)
[fluet@lennon foo]$ mlton-stable foo.sml
foo.sml:2.20-2.21 Error: unify: not an int
t1: 'a1890 list
t2: int
operatorPlus_0
{canGeneralize = false,
flexes = [],
tyvars = ('a),
ty = (Con ->
(((Var 'a), (Var 'a)), (Var 'a)))}
in function
[]
types =
((Con ->
(((Con int ()), (Con int ())), (Con int ()))),
(Con ->
(((Con intInf ()), (Con intInf ())), (Con intInf ()))),
(Con ->
(((Con word ()), (Con word ())), (Con word ()))),
(Con ->
(((Con word8 ()), (Con word8 ())), (Con word8 ()))),
(Con ->
(((Con real ()), (Con real ())), (Con real ()))))
instance =
(Con ->
(((Con list ((Var 'a_75))), (Con list ((Var 'a_75)))), (Con list ((Var
'a_75)))))
mlton: impossible use of overloaded var
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):
[fluet@lennon foo]$ cat foo.sml
fun sum [] = 0
| sum (h::t) = h + (sum h)
[fluet@lennon foo]$ mlton-stable foo.sml
foo.sml:2.20-2.21 Error: unify: not an int
t1: 'a1884 list
t2: int
08048000-08693000 r-xp 00000000 03:06 4905 /home/fluet/mlton/mlton-stable-20020214-08:12:05/lib/mlton-compile
08693000-08742000 rw-p 0064a000 03:06 4905 /home/fluet/mlton/mlton-stable-20020214-08:12:05/lib/mlton-compile
08742000-08755000 rwxp 00000000 00:00 0
40000000-40012000 r-xp 00000000 03:06 83473 /lib/ld-2.1.3.so
40012000-40013000 rw-p 00011000 03:06 83473 /lib/ld-2.1.3.so
40013000-40014000 rw-p 00000000 00:00 0
40014000-40015000 ---p 00001000 00:00 0
40015000-40019000 rw-p 00002000 00:00 0
40019000-4001a000 ---p 00006000 00:00 0
4001f000-4003c000 r-xp 00000000 03:06 83479 /lib/libm-2.1.3.so
4003c000-4003d000 rw-p 0001c000 03:06 83479 /lib/libm-2.1.3.so
4003d000-4005e000 r-xp 00000000 03:06 21430 /usr/local/lib/libgmp.so.3.1.1
4005e000-4005f000 rw-p 00020000 03:06 21430 /usr/local/lib/libgmp.so.3.1.1
4005f000-4013e000 r-xp 00000000 03:06 83474 /lib/libc-2.1.3.so
4013e000-40143000 rw-p 000de000 03:06 83474 /lib/libc-2.1.3.so
40143000-40146000 rw-p 00000000 00:00 0
b0000000-bf8ce000 rw-p 00000000 00:00 0
bfffd000-c0000000 rwxp ffffe000 00:00 0
Out of swap space: cannot obtain 328155136 bytes.