[MLton] Bug with tuple selection

Matthew Fluet fluet at tti-c.org
Sun Nov 25 17:05:01 PST 2007


On Sun, 25 Nov 2007, Wesley W. Terpstra wrote:
> 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

Confirmed.  Clearly a bug with flexible record resolution.  Changing the 
code to:
   fun f (a as {value = _, offset = _},
          b as {value = _, offset = _})  = Int.< (#value a, #value b)
elimintes the bug.




More information about the MLton mailing list