[MLton] Overflow Exception

Matthew Fluet fluet@cs.cornell.edu
Tue, 14 Sep 2004 22:29:03 -0400 (EDT)


> I converted a
> small parsing program which uses mlyacc/mllex which runs fine in SML/NJ.
>
> When I run it against a small 5-6 line file I get an immediate
> "unhandled exception: Overflow"

Does the Overflow occur without any input file?  If so, then it is
probably some top-level computation which gets run before the parser even
gets going.

Are you by chance using the SMLNJ-Lib?  In the BitArray implementation,
there is a maxLen computation given by:
           val maxLen = 8*Word8Array.maxLen
This is fine in SML/NJ where Word8Array.maxLen is 16777215, but in MLton,
Word8Array.maxLen = valOf(Int.maxInt), so the computation overflows. I
replaced the code by:
           val maxLen = (8*Word8Array.maxLen)
                        handle Overflow => Word8Array.maxLen