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

Magnus Henoch magnus@REDACTED
Mon Nov 10 12:31:47 CET 2014


Mattias Waldau <mattias.waldau@REDACTED> 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.

Regards,
Magnus



More information about the erlang-bugs mailing list