[MLton] Implementing warnExnMatch

Matthew Fluet fluet@cs.cornell.edu
Wed, 27 Jul 2005 15:32:32 -0400 (EDT)


> > I will note that SML/NJ raises a hard error in the case of 
> > a redundant rule, so it is not even possible to compile code with 
> > redundant rules.  
> 
> I do not see this with SML/NJ 110.54.  It appears to give a warning,
> not an error.

I definitely get an error:

-bash-2.05b$ sml
Standard ML of New Jersey v110.54 [built: Mon May 23 12:04:48 2005]
- datatype t = A | B;
datatype t = A | B
- val f = fn A => () ; 
stdIn:2.9-2.19 Warning: match nonexhaustive
          A => ...
  
val f = fn : t -> unit
- val g = fn A => () | A => ();
stdIn:3.9-3.29 Error: match redundant and nonexhaustive
          A => ...
    -->   A => ...
  
- g;
stdIn:1.1 Error: unbound variable or constructor: g
- val h = fn A => () | B => () | A => ();
stdIn:1.9-2.19 Error: match redundant
          A => ...
          B => ...
    -->   A => ...
  
- h;
stdIn:1.1 Error: unbound variable or constructor: h

Whether it gives an error or a warning appears to be under the control of
Control.MC.matchRedundant{Error,Warn}.

-bash-2.05b$ sml
Standard ML of New Jersey v110.54 [built: Mon May 23 12:04:48 2005]
- Control.MC.matchRedundantError := false;
val it = () : unit
- datatype t = A | B;
datatype t = A | B
- val g = fn A => () | B => () | A => ();
stdIn:3.9-3.39 Warning: match redundant
          A => ...
          B => ...
    -->   A => ...
  
val g = fn : t -> unit

But, I believe the default behavior is to error.