[erlang-bugs] Double evaluation when using weird record syntax

Dominic Williams <>
Sun Dec 23 19:20:34 CET 2007


Hello,

The compiler seems to generate a double evaluation in the 
following case:

-module(double_evaluation).
-export([run/0]).
-record(r, {f}).

maker(F) ->
     io:format("maker(~p)~n",[F]),
     #r{f=F}.

run()->
     (maker(1))#r{f=0},
     (maker(2))#r{}.      % maker/1 called twice


Eshell V5.5.4  (abort with ^G)
1> c(double_evaluation).
{ok,double_evaluation}
2> double_evaluation:run().
maker(1)
maker(2)
maker(2)
{r,2}


I am not even sure what it should mean to use #r{} after an 
expression with nothing between the braces, but this turned 
up in some production code, and the double evaluation 
appeared sometime after R8, causing a new bug in our system.

Regards,

Dominic Williams
http://dominicwilliams.net

----




More information about the erlang-bugs mailing list