[erlang-bugs] Parser bug: if missing ", " in list between records, the first is ignored, and no parser warnings are given.

Tuncer Ayaz tuncer.ayaz@REDACTED
Sun Nov 16 17:41:35 CET 2014


On Mon, Nov 10, 2014 at 12:31 PM, Magnus Henoch wrote:
> Mattias Waldau writes:
>
> > Thank you Loic and Roland for the explanations, I really
> > appreciate it.
> >
> > The trick to understand why this is and should be ok is that #{}
> > is n operator and then it makes sense. Then, there is another
> > question why #{} is an operator.
> >
> > This is what the Erlang reference manual says about record
> > creation, it doesn't mention #rec{}#rec{}
> >
> > So, until you explained, I just thought is was a parser bug.
>
> This syntax used to be disallowed. The "Nested records" section of
> the Records chapter of the reference manual mentions a new feature
> in R14:
>
>     Before R14 you would have needed to use parentheses as following:
>
>     "nested0" = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0.name,
>     N0n = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0{name = "nested0a"},
>
>
>     Since R14 you can also write:
>
>     "nested0" = N2#nrec2.nrec1#nrec1.nrec0#nrec0.name,
>     N0n = N2#nrec2.nrec1#nrec1.nrec0#nrec0{name = "nested0a"},
>
> As an unintended(?) consequence, this also made the #rec{}#rec{}
> syntax valid.

When I forward-ported and submitted the old patch and it was included
in R14, unfortunately both the OTP board and I failed to see that
particular problem. After R14 was released and users hit that issue,
Robert Virding and I discussed this in detail and we suggested to back
out that change. However, so far there has been no response from the
OTP team. So, personally, like Robert, I still think we should revert
the change, as the gain is not worth it given that users accidentally
write such code.



More information about the erlang-bugs mailing list