[erlang-questions] Is it a compiler bug?

Robert Raschke <>
Thu Apr 13 15:42:39 CEST 2017


This is because the first record constructor returns as its value the
record and the seemingly second constructor then functions as a record
modification.

It is parsed as (*#a{field1 = 1})#a{field1 = 2}*

Cheers,
Robby

On 13 Apr 2017 15:27, "Minin Maxim" <> wrote:

Hello,



i'm confused about a very simple module like this:

-----------------------------------------------------------------------

*-module(sample).*



*-record (a, {field1}).*



*-export([bug/0]).*



*bug() ->*

*                [*

*                #a{field1 = 1} %% COMMA IS MISSING*

*                #a{field1 = 2},*

*                #a{field1 = 3}*

*                ].*

-----------------------------------------------------------------------



Why can it be compiled?



*Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:4:4] [async-threads:10]
[hipe] [kernel-poll:false]*



*Eshell V8.3  (abort with ^G)*

*1> c("sample.erl").*

*{ok,sample}*

*2> sample:bug().*

*[{a,2},{a,3}]*



And eshell do it to:



*3> rr(sample).*

*[a]*

*4> [#a{field1 = 1} #a{field1 = 2}, #a{field1 = 3}].*

*[#a{field1 = 2},#a{field1 = 3}]*

*5>*



Do I understand something wrong or is it a compiler bug?



Thanks

Maxim

_______________________________________________
erlang-questions mailing list

http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170413/8f441a91/attachment.html>


More information about the erlang-questions mailing list