[MLton] modifying flatten.fun to always flatten

Stephen Weeks MLton@mlton.org
Sun, 18 Jan 2004 13:24:27 -0800

> During a fix point, in the second round compilation, the compiler reaches
>  the knowcase part of simplify (about 4-5 steps after flatten is called
> and localflatten3). I then recieve the following compiler message -
> MLton raised in 430.56 + 0.00 (0% GC)
> unhandled exception: Option
> Could someone give a rough overview of
> what knowcase does and any potential interactions with tupples.

The bug is almost certainly not in knownCase, which runs very soon
after flatten.  Rather the bug is probably because flatten produces
invalid SSA.

When working on SSA passes, it is best to do two things.  First, run
with -type-check true, which will cause the the SSA type checker to
run after each simplifier pass.  This will catch a lot of bugs.
Second, turn of the shrinker in the pass you are working on.  In the
case, you just need to comment out a little bit at the bottom of

Hopefully you will then see a type error immediately after the flatten
pass, and that will give a clue what is going wrong.