[MLton] 2004 bug reports

Tom Murphy tom7@cs.cmu.edu
Sat, 17 Jan 2004 16:11:58 -0500 (EST)

Thanks for your help getting mlton-2004 compiled on my machine. I like
the new mlton a lot! It's great to not have to support both mlton and
SML/NJ for type-checking (especially since they are so slow about
fixing bugs), and the error messages are really great. I found a bunch
of bugs and things you might want to know about.

I had to change the #!interpreter in the 'mlton' script to invoke bash2
instead of my old bash, otherwise I get this error:

[root@spacebar /root]# mlton @MLton gc-summary -- test.sml
/usr/local/bin/mlton: [: --: unary operator expected
@MLton missing --

(This also causes bootstrapping to fail.)

I tried compiling ConCert with mlton after updating it for the 2002 basis

    fun localhost () =
            val sys_gethostname = _ffi "gethostname" :
                CharArray.array * int -> int ;
            val buf = Unsafe.CharArray.create 512
            sys_gethostname (buf, 511)

Error: raw-network.sml 63.18: function applied to incorrect argument
   expects: [CharArray.array] * _
   but got: [Unsafe.CharArray.array] * _
   in: sys_gethostname (buf, 511)

The UNSAFE sig on the mlton page seems to indicate that these should be
the same type. (It would be nice if the UNSAFE_* sigs were included in the
user guide; I don't know where else to find those.) Certainly Unsafe is
pretty useless if the types are different.

I realize that the basis 1997 is now deprecated, but in that mode,
LargeWord.toString apparently expects Word64.word even though the
Word64 structure is not bound:

Warning: -basis is deprecated
Error: compile.sml 54.17: function applied to incorrect argument
   expects: [Word64.word]
   but got: [word]
   in: LargeWord.toString (Posix.Process.p  ...  Posix.ProcEnv.getpid ()))

(changed to Word64.toString)

Warning: -basis is deprecated
Error: compile.sml 54.17: undefined structure Word64

I ran mlton on some of the TILT tests. Here's some bugs with the parser:

The lex item after infix(r) should be DIGIT, not INT.
mlton accepts, but should reject:

infix 00 x
infix ~0 x

infix 0x0 l

... ditto with infixr.

mlton should all of the one-liners below. See the def'n page 12:

        "No datdesc, valdesc, or exdesc may describe true, false,
         nil, ::, or ref."

val rec op :: = fn x => x

val rec nil = fn x => x

val rec true = fn x => x

val rec ref = fn x => x

mlton is not good at detecting duplicates, except for pattern variables.
It should reject these:

datatype ('a, 'a) a = A

datatype a = A | A

fun f x = x
and f x = x

datatype t = A
and t = B

val x = { a = 1, a = 1 }

val x = 1
and x = 2

type x = int
and x = int

exception X and X