[MLton] Catching redundant pattern matches

Stephen Weeks MLton@mlton.org
Sun, 12 Dec 2004 15:02:42 -0800


> Also, is your redundant case inside the body of an (unused) functor?
> It turns out that we perform match compilation (and discover
> exhaustive/redundant matches) on the defunctorized program.
...
> This is probably reason enough to move the match compilation into
> the elaborator.

One reason we do match compilation after defunctorization is because
of exception aliasing.  I guess other implementations just assume
exceptions aren't aliased, which generates redundant tests in some
cases (not that this really matters for performance).

Not warning about matches in unused functors is clearly a bug.
Perhaps the right solution is to do match compilation in the
elaborator just for the purposes of warnings, and then do match
compilation after defunctorization to generate code.  It is
duplication of work, but may not be too costly.