[MLton] Catching redundant pattern matches
Sun, 12 Dec 2004 16:56:28 -0500 (EST)
> > I am surprised MLton did not warn about this, as there is code to
> > point out redundant matches. As an experiment, I tried compiling the
> > following code with MLton.
> Hmm, it is related to .mlb files. I am running a recent HEAD from CVS:
> MLton MLTONVERSION (built Mon Dec 06 17:10:31 2004 on mushroom.home)
> sources from right before the compile. I have an ''ann'' in scope with
> all warnings. For fun, I altered the code to have a redundant
> case v of
> NONE =>
> | SOME x =>
> | SOME y =>
> and the only thing I get is the ''unused variable y'' which proves the
> annotations are inside the scope, but the redundant case was never
> reported. I will try updating to recent sources and then check again.
What are the precise annotations that you are using?
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.
So, the following program:
functor F () : sig val foo : 'a list * 'b list -> unit end = struct
fun foo (ss, rs) =
case (ss, rs) of
(, regs) => ()
| (s :: ss, r :: rs) => ()
| (ss, ) => ()
| (, ) => ()
prints no redundant warning. This is probably reason enough to move the
match compilation into the elaborator.