Re: bug to do with as-binding masking datatype constructor name
Andreas Rossberg <[email protected]> Tue, 19 Apr 2011 16:26:15 +0200
| Newsgroups | gmane.comp.lang.ml.mlton.devel,gmane.comp.lang.ml.polyml.general |
|---|---|
| Message-ID | <[email protected]> |
On Apr 13, 2011, at 15.44 h, Matthew Fluet wrote: > On Wed, Apr 13, 2011 at 2:49 AM, Andreas Rossberg <[email protected] > > wrote: >> On Apr 13, 2011, at 01:49, Michael Norrish wrote: >>> >>> Poly 5.3 rejects >>> >>> datatype foo = bar of string >>> >>> fun f x = let >>> val bar as y = 3 >>> in >>> bar + x >>> end >>> >>> MLton 20091212~svn accepts it. >>> >>> Who's right? >> >> Mlton, although this is arguably a design bug of the language. > > I was going to conclude that Poly/ML is right. > > I don't see why rule (43) applies to the "bar as y" pattern; it is not > the case that "bar \notin Dom(C)" (because "bar" is in scope) and it > is not the case that "is of C(vid) = v" (because "bar" has constructor > status). MLton omits those two antecedents in its implementation of > "as"-pattern elaboration. (Similarly, HaMLet omits them.) > > On the other hand, "val rec bar as y = fn() => 3" would allow changing > the identifier status of "bar" (rule (26) and comment). Matthew is right, I was considering the wrong case: in a non-recursive binding this should not be accepted. (Also, I should fix Hamlet :) ). /Andreas