[erlang-bugs] BugReport_syntax_tools_invalid_number_string

Constantin Malikov kostiamalikov@REDACTED
Wed Nov 13 05:05:00 CET 2013


Hello , friends. I want to tell you about a bug in Erlang:

 I have differences between result of using methods map() and input data. I
attached simple sample, where you can see this differences.

 1) For getitng syntax tree input:

_______________________________________________________________________

{ok, Forms} = epp:parse_file("example.erl", [], []).

_______________________________________________________________________

 You get this:

_______________________________________________________________________
{ok,[{attribute,1,file,{"example.erl",1}},
     {attribute,1,module,example},
     {attribute,3,export,[{handle_event,2}]},
     {function,5,handle_event,2,
               [{clause,5,
                        [{var,5,'_'},{var,5,'_'}],
                        [],
                        [{cons,6,
                               {tuple,6,[]},
                               {cons,7,{nil,7},{cons,8,{...},...}}}]}]},
     {eof,9}]}
_______________________________________________________________________

2) Then input:

_______________________________________________________________________

io:format("~p~n",[Forms]).

_______________________________________________________________________

 You get this:

_______________________________________________________________________
[{attribute,1,file,{"example.erl",1}},
 {attribute,1,module,example},
 {attribute,3,export,[{handle_event,2}]},
 {function,5,handle_event,2,
     [{clause,5,
          [{var,5,'_'},{var,5,'_'}],
          [],
          [{cons,6,
               {tuple,6,[]},
               {cons,7,
                   {nil,7},
                   {cons,8,
                       {cons,8,{atom,8,asd},{cons,8,{atom,8,asd},{nil,8}}},
                       {nil,8}}}}]}]},
 {eof,9}]
ok

_______________________________________________________________________

 3) Then input:

_______________________________________________________________________

Form = {function,5,handle_event,2,
     [{clause,5,
          [{var,5,'_'},{var,5,'_'}],
          [],
          [{cons,6,
               {tuple,6,[]},
               {cons,7,
                   {nil,7},
                   {cons,8,
                       {cons,8,{atom,8,asd},{cons,8,{atom,8,asd},{nil,8}}},
                       {nil,8}}}}]}]}.

_______________________________________________________________________

 You get:

_______________________________________________________________________{function,5,handle_event,2,
          [{clause,5,
                   [{var,5,'_'},{var,5,'_'}],
                   [],
                   [{cons,6,
                          {tuple,6,[]},
                          {cons,7,
                                {nil,7},
                                {cons,8,
                                      {cons,8,{atom,8,asd},{cons,8,...}},
                                      {nil,8}}}}]}]}

_______________________________________________________________________

 4) Now, I will try to traverse the data via erl_syntax_lib:map():

_______________________________________________________________________

erl_syntax_lib:map(fun (El) -> io:format("~p~n", [erl_syntax:revert(El)]),
El end, Form).

_______________________________________________________________________

 You get:

____________________________________________
{atom,5,handle_event}
{var,5,'_'}
{var,5,'_'}
{tuple,6,[]}
{nil,7}
{atom,8,asd}
{atom,8,asd}
{cons,8,{atom,8,asd},{cons,8,{atom,8,asd},{nil,8}}}
{cons,6,
      {tuple,6,[]},
      {cons,6,
            {nil,7},
            {cons,6,
                  {cons,8,{atom,8,asd},{cons,8,{atom,8,asd},{nil,8}}},
                  {nil,8}}}}
{clause,5,
        [{var,5,'_'},{var,5,'_'}],
        [],
        [{cons,6,
               {tuple,6,[]},
               {cons,6,
                     {nil,7},
                     {cons,6,

{cons,8,{atom,8,asd},{cons,8,{atom,8,asd},{nil,8}}},
                           {nil,8}}}}]}
{function,5,handle_event,2,
    [{clause,5,
         [{var,5,'_'},{var,5,'_'}],
         [],
         [{cons,6,
              {tuple,6,[]},
              {cons,6,
                  {nil,7},
                  {cons,6,
                      {cons,8,{atom,8,asd},{cons,8,{atom,8,asd},{nil,8}}},
                      {nil,8}}}}]}]}
{tree,function,
    {attr,5,[],none},
    {func,
        {tree,atom,{attr,5,[],none},handle_event},
        [{tree,clause,
             {attr,5,[],none},
             {clause,
                 [{var,5,'_'},{var,5,'_'}],
                 none,
                 [{tree,list,
                      {attr,6,[],none},
                      {list,
                          [{tuple,6,[]},{nil,7},{tree,list,{...},...}],
                          {nil,8}}}]}}]}}

_______________________________________________________________________

 Part of initial datas is:

_______________________________________________________________________
[{cons,6,
               {tuple,6,[]},
               {cons,7,
                   {nil,7},
                   {cons,8,
                       {cons,8,{atom,8,asd},{cons,8,{atom,8,asd},{nil,8}}},
                       {nil,8}}}}]

_______________________________________________________________________

 But i get:

_______________________________________________________________________
[{cons,6,
              {tuple,6,[]},
              {cons,6,
                  {nil,7},
                  {cons,6,
                      {cons,8,{atom,8,asd},{cons,8,{atom,8,asd},{nil,8}}},
                      {nil,8}}}}]

_______________________________________________________________________

 Unexpected change original:
“{cons,7,” to “{cons,6,” and “{cons,8,” to “{cons,6,”.

 Tested by Erlang 16B02 syntax_tools-1.6.11, and R15B02, syntax_tools-1.6.9


__________________________example.erl____________________________________-module(example).

-export([handle_event/2]).

handle_event( _, _) ->
    [    {},
        [],
        [asd,asd] ].

_______________________________________________________________________

With best regards,

Malikov Constantin, software developer, Eltex.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20131113/b8c00ce6/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: syntax_tools_invalid_number_string.tar.gz
Type: application/x-gzip
Size: 21369 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20131113/b8c00ce6/attachment.bin>


More information about the erlang-bugs mailing list