Re: Re: A Possible "Bug"?

"Baojian Hua" <[email protected]>
Newsgroups gmane.comp.lang.ml.mlton.devel
Message-ID <23980370.1519281261460836756.JavaMail.coremail@mailweb>


> -----Original E-mail-----
> From: "Matthew Fluet" <[email protected]>
> Sent Time: 2009-12-19 1:02:21
> To: "Henry Cejtin" <[email protected]>
> Cc: "Baojian Hua" <[email protected]>, mlton <[email protected]>
> Subject: Re: [MLton] A Possible "Bug"?
> 
> On Fri, Dec 18, 2009 at 9:15 AM, Henry Cejtin
> <[email protected]> wrote:
> > I  would  say  that  MLton is correct and SML/NJ is wrong.
> 
> Agreed, with the caveat noted below.
> 
> > The point is
> > that the left hand side of the binding in
> >    val [[x]] = []
> > is a non-exhaustive pattern and the right hand side does not match any of
> > the  cases.  (The type is correct though.)  Hence evaluating this should
> > result in the Bind exception being raised.
> >
> > At least in v110.67 of SML/NJ, that is what happens.
> >
> > Perhaps you are being confused by the fact that  the  exception  raising
> > happens  at  evaluation  time.   In  MLton,  that  is  when  you run the
> > executable, but in SML/NJ, it is when you enter the  expression  to  the
> > read-eval-print loop.
> 
> There is a subtle difference in SML/NJ's behavior:
> 
> Standard ML of New Jersey v110.71 [built: Thu Oct  1 09:13:22 2009]
> - val [[x]] = [];
> 
> unexpected exception (bug?) in SML/NJ: Bind [nonexhaustive binding failure]
>   raised at: stdIn:1.5-1.15
>              ../compiler/MiscUtil/print/ppobj.sml:396.20
>              ../compiler/TopLevel/interact/evalloop.sml:44.55
> 
> - val SOME x = NONE;
> 
> unexpected exception (bug?) in SML/NJ: Bind [nonexhaustive binding failure]
>   raised at: stdIn:1.5-1.18
>              ../compiler/MiscUtil/print/ppobj.sml:396.20
>              ../compiler/TopLevel/interact/evalloop.sml:44.55
> 
> - val NONE = SOME 1;
> 
> uncaught exception Bind [nonexhaustive binding failure]
>   raised at: stdIn:1.5-1.18
> 
> The last is what I would expect to see in all cases.  The others seem
> to be a case where the the REPL isn't expecting a Bind exception; it
> seem to be related to patterns that should be binding variables (i.e.,
> they are entered into the static environment), but then are not bound
> due to the pattern match failure (i.e, they are not entered into the
> dynamic environment).
> 
Yes, I'd tried it.

And reading the compiler output:
  unexpected exception (bug?) in SML/NJ: Bind [nonexhaustive binding failure]

it seems that SML/NJ treats it a bug in itself, rather than a Binding exception.
(Though I've not read its source code.)

> > Note,  if  SML/NJ  did  not  issue a warning about the binding not being
> > exhaustive then that would be a bug in their code.
> 
> Except that the Defn states: "However, this warning should not be
> given when the binding is a component of a top-level declaration...."
> MLton gives pattern-match warnings in all cases.
> 
> 
> > ----- Original Message ----
> > From: Baojian Hua <[email protected]>
> > To: mlton <[email protected]>
> > Sent: Fri, December 18, 2009 4:02:57 AM
> > Subject: [MLton] A Possible "Bug"?
> >
> > ...
> >
> > However, I happened to run this code:
> > val [[x]] = [];
> >
> > MLton reports a warning message, but smlnj-110.71 reports
> > an error (compiler bug?). I'd like to ask here that which
> > behaves correctly?
> >
> > _______________________________________________
> > MLton mailing list
> > [email protected]
> > http://mlton.org/mailman/listinfo/mlton
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.