[MLton] bug to do with as-binding masking datatype constructor
name
Andreas Rossberg
rossberg at mpi-sws.org
Tue Apr 19 07:26:15 PDT 2011
On Apr 13, 2011, at 15.44 h, Matthew Fluet wrote:
> On Wed, Apr 13, 2011 at 2:49 AM, Andreas Rossberg <rossberg at mpi-sws.org
> > 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
More information about the MLton
mailing list