[MLton] A little bug

Stephen Weeks MLton@mlton.org
Thu, 10 Nov 2005 15:45:07 -0800

> Indeed, also a bug.  While the pass that manifests the bug is
> refFlatten, it turns out that the actual bug is in the SSA2
> shrinker.

Thanks for finding the bug.  I am thankful it wasn't in refFlatten,
which has been a never ending source of problems.

> The problem is that the tuple (re)construction optimization in the
> SSA2 shrinker should not occur when either the newly constructed
> tuple or the original tuple contains mutable fields.
> It's probably all of a 2 or 3 line fix to the shrinker.

The test was already there to turn off tuple reconstruction if the
original tuple is mutable.  I added the test to turn it off if the
reconstructed tuple is mutable.

BTW, in looking at the code, I noticed that we only do tuple
reconstruction for anonymous tuples (i.e. those with no constructor).
There's no reason we shouldn't do it for tuples with a specific
constructor too.  If anyone is interested in learning about the SSA
shrinker and making a simple improvement, that would be a good one to
do.  We'd be happy to answer any questions.