[MLton] Bug with tuple selection

Matthew Fluet fluet at tti-c.org
Thu Nov 29 12:04:57 PST 2007


On Sun, 25 Nov 2007, Wesley W. Terpstra wrote:
> The version: cvs HEAD/powerpc
>
> The error:
>>    xmlSimplify starting
>>  	    typeCheck starting
>>  Type error: actual and formal not of same type
>>  actual: ('a_4092 * word32) * (word32 * word32)
>>  formal: (word32 * word32) * (word32 * word32)
>>  expression: f x_0
>>       typeCheck raised in 0.06 + 0.00 (0% GC)
>
> The code:
>>  fun f (a, b) = Int.< (#value a, #value b)
>>
>>  fun copyTo (array, record as {value, offset}) =
>>    Array.update (array, 1, { value=value, offset = 3 })
>>
>>  fun fixTooBig (array, record) =
>>    let val left = Array.sub (array, 1)
>>        val right = Array.sub (array, 2)
>>        val small = if f (left, right) then left else right
>>    in  if f (record, small)
>>        then copyTo (array, record)
>>        else copyTo (array, small)
>>    end

Fixed.  There was a bug in the inference of flexible record components. 
See
   http://mlton.org/cgi-bin/viewsvn.cgi?rev=6229&view=rev
for details.

I will point out that MLton is exceptionally liberal in infering the 
components of flexible records.  No other SML compiler I have access would 
type check the program; they all report unresolved flex records at the 
definition of f.




More information about the MLton mailing list