Parser error regression for ERTS V5.8.3
Jesper Louis Andersen
jesper.louis.andersen@REDACTED
Wed Dec 22 19:08:32 CET 2010
Consider the following module:
==
-module(foo).
-compile(export_all).
-record(foo, { bar }).
x() ->
[ #foo { bar = 1}
#foo { bar = 2}
#foo { bar = 3}].
==
In ERTS V5.8.3 this is valid (notice the lack of commas at the end of
each line). It is also valid in V5.8.1, but it fails on V5.7.4:
./foo.erl:9: syntax error before: '#'
./foo.erl:4: Warning: record foo is unused
The result of foo:x(). is:
Erlang R14B02 (erts-5.8.3) [source] [64-bit] [smp:2:2] [rq:2]
[async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.8.3 (abort with ^G)
1> c(foo).
{ok,foo}
2> foo:x().
[{foo,3}]
3>
which I find highly confusing and wrong.
The parse derivation is: expr -> list -> tail -> expr -> record_expr
--(by the last clause erl_parse.yrl L351)--> record_expr ....
(parse derivation from commit 609e7ade98c)
git annotate lib/stdlib/src/erl_parse.yrl points to commit 3829e5fa ..:
Support nested record field access without parentheses.
... (omitted rest of the commit)
git show 3829e5fa
So it has to do with the introduction of nested records without
parenthesis. I suggest to revert the patch and add something like the
above as a SHOULD_FAIL test case to the parser tests.
(We found it on the IRC channel because someone asked why a Nitrogen
tutorial slide had this and it worked. It was a mistake in the
tutorial as the successor slides add the commas but things make on
boggle and wonder).
--
J.
More information about the erlang-bugs
mailing list