[MLton] front-end functor bug

Stephen Weeks MLton@mlton.org
Fri, 6 Feb 2004 19:23:51 -0800

> > The body of a functor is elaborated when the functor is defined.  If
> > -warn-match is true, then the body is re-elaborated at each
> > application of the functor.
> Is that just to catch the cases when there are exceptions (used
> in patterns) in the argument of the functor?  

That could be that case, but it isn't.  Match compilation occurs on
the CoreML produced by the elaborator, so that's when match warnings
get reported (for exceptions and other types).  If we stop running
MLton after producing the CoreML but before producing XML, then we
won't get any match warnings.

The fact that we can't get redundant match warnings for exceptions
until after defunctorization is one push in the direction of keeping
match compilation where it is, and not trying to push it earlier, into
the elaborator.

> Still, it's rather confusing to have the error message refer to the
> functor body, not the functor application.

There are two source positions that are responsible for the error.  I
think either one by itself is equally confusing.  It would be nice to
list both, but I'm not convinced its worth the work for me to do this.
I wouldn't object if somebody else wanted to.