[erlang-bugs] compile and syntax_tools disagree

Ulf Wiger (TN/EAB) <>
Mon Apr 2 18:48:00 CEST 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20070402/4010393b/attachment.html>


More information about the erlang-bugs mailing list