[MLton] Bug with "polymorphic" exns

Stephen Weeks MLton@mlton.org
Mon, 24 Jan 2005 11:57:02 -0800

> I recently discovered that MLton rejects the following program:
>    val x = let exception E of 'a in () end;
> Although not very useful code, it should be accepted.

I disagree that it should be accepted.  The type variable 'a is
implicitly bound at the outermost val declaration (val x = ...), and
let expressions are expansive.  Hence, the value restriction requires
the program to be rejected.  MLton's error message correctly indicates
the problem, although it doesn't explicitly mention the value
restriction because I felt it was too technical of a term to appear in
an error message.

Error: z.sml 1.9.
  Can't bind type variable: 'a.
    in: val 'a x = let exception E of 'a in () end