[MLton] A little bug

Matthew Fluet fluet@cs.cornell.edu
Thu, 10 Nov 2005 15:17:18 -0500 (EST)


> I attached a tgz file containing a little SML program bug.sml and a data
> file data.  This is what happens when I try out mlton.
>
> The exception is raised by (TextIO.scanStream Time.scan is)
> where is is a stream opened with TextIO.openIn on the file data that
> contains
>
> SpreadExp 0.201
> RegInf 0.417
> MulInf 0.259
> Knorm 0.017
>
> It fails on ' 0.417' but that should not be a problem for Time.scan.
>
> To me this looks like a bug.

Indeed, there was an Overflow in the calculation of the number of 
nanoseconds from the fractional seconds.  At one point, we represented 
Time.time as the pair of seconds/microseconds.  Then we went to 
representing it as just microseconds.  Then, we went to representing it as 
just nanoseconds.  This last change caused a problem, since the 
calculation of nanoseconds from fractional seconds was done at Int32.int, 
which wasn't large enough to hold some intermediate results.  I've changed 
it so that the computation is done at IntInf.int.

I also discovered a latent bug, where an explicit sign was expected to be 
followed by a digit, but the Basis Library specification grammar specifies 
that an explicit sign may be followed by a decimal and then digits.