[MLton] confusing error message from MLton

Henry Cejtin henry@sourcelight.com
Mon, 21 Jun 2004 13:38:16 -0500


I'm  confused  by why MLton is flagging an error in the following (incorrect)
code on line 14, column 29:

===========================================================================
fun fib x =
       if x <= 1
          then x
          else fib (x - 1) + fib (x - 2)

fun fiba x =
       if x <= 1
          then x
          else fibb (x - 1) + fibb (x - 2)

fun fibb x =
       if x <= 1
          then x
          else fiba (x - 1) + fiba (x - 2)

def doOne arg =
       case Int.fromString arg of
         SOME arg' =>
            (print (arg ^ " => ");
             print (Int.toString (fib arg') ^ "\n"))

       | _ =>
            print ("\"" ^ String.toString arg ^ "\" is not an integer\n")
===========================================================================

The error is
    14.29: syntax error: inserting VAL
which  certainly  confused  me.  I would have expected first to get the error
about fiba referring to fibb (because the third `fun' should be `and').  Then
I  would  expect it would have either complained about `def' being unbound or
else about no `fun' before `def'.