[erlang-bugs] compile and syntax_tools disagree

Bjorn Gustavsson bjorn@REDACTED
Tue Apr 3 10:30:31 CEST 2007


As far as I understand, The ERTS User's Guide says that you'll need two
layers of lists to represent a guard sequence.

syntax_tools still accepts the older format of guards (before semicolons
in guards were introduced), so that it can still be used for the abstract
format in old Beam files.

So as I see, there is no bug.

/Björn

"Ulf Wiger \(TN/EAB\)" <ulf.wiger@REDACTED> writes:

> I'm getting a bit cross-eyed, but this has got to be a bug *somewhere*:
> 
> 12> M = [{attribute,1,module,m},{attribute,1,export,[{foo,1}]}|Fs] ++
> [{eof,1}]. 
> [{attribute,1,module,m},
>  {attribute,1,export,[{foo,1}]},
>  {function,1,
>            foo,
>            1,
>            [{clause,1,
>                     [{var,1,'R'}],
>                     [{op,1,'==',{var,1,'R'},{integer,1,1}}],
>                     [{atom,1,true}]}]},
>  {eof,1}]
> 13> compile:forms(M).
> .:none: internal error in expand_module;
> crash reason: {function_clause,
>                   [{erl_expand_records,
>                        guard_tests1,
>                        [{op,1,'==',{var,1,'R'},{integer,1,1}},
> ...
>                    {erl_expand_records,guard_tests,2},
>                    {erl_expand_records,guard,2},
>                    {erl_expand_records,clauses,2},
>                    {erl_expand_records,forms,2},
>                    {erl_expand_records,forms,2},
>                    {erl_expand_records,module,2},
>                    {sys_pre_expand,module,2}]}
> error
> 14> M1 = [{attribute,1,module,m},{attribute,1,export,[{foo,1}]}|Fs1] ++
> [{eof,1}].
> [{attribute,1,module,m},
>  {attribute,1,export,[{foo,1}]},
>  {function,1,
>            foo,
>            1,
>            [{clause,1,
>                     [{var,1,'R'}],
>                     [[{op,1,'==',{var,1,'R'},{integer,1,1}}]],
>                     [{atom,1,true}]}]},
>  {eof,1}]
> 15> compile:forms(M1).
> {ok,m,
>  
> <<70,79,82,49,0,0,1,184,66,69,65,77,65,116,111,109,0,0,0,50,0,0,0,6,1,10
> 9,
>       ...>>}
> 
> When pretty-printing the two form lists using erl_prettypr:format/2, 
> you get the same output, and according to the ERTS User's Guide,
> the two guard representations should be equivalent. A list of lists
> in the Guard represents a disjunction, and a list of Guard expressions
> represents a conjunction. In this case, there's only one guard expr.
> 
> 6> erl_prettypr:format(erl_syntax:form_list(Fs)).
> "foo(R) when R == 1 -> true."      
> 6> erl_prettypr:format(erl_syntax:form_list(Fs1)).
> "foo(R) when R == 1 -> true."      
> 
> It seems to me as if the bug is in the compiler (version 4.4.3).
> 
> Forgive me for not diving into the compiler source code to verify
> this claim. Time to put the kids to sleep.
> 
> BR,
> Ulf W
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-bugs

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB




More information about the erlang-bugs mailing list