Skip to content

Mixer does not handle {eof, {Line, Column}} syntax #15

Description

@reganheath

Describe the problem

Compiling with OTP 24 I got the stacktrace below. A quick look into the issue and I found the AST for EOF was not {EOL, Line} as mixer expected, but {EOL, {Line, Column}}.

See https://erlang.org/doc/apps/erts/absform.html#representation-of-parse-errors-and-end-of-file for a description of {EOL, {Line, Column}} and https://erlang.org/doc/man/erl_anno.html#type-location for more detail.

Software Version

Windows, OTP 24, rebar3.

Replication Case

Just run rebar3 eunit on mixer itself.

Stacktrace

apps/edweb/src/handler_test.erl:none: error in parse transform 'mixer': {badarith,
                                   [{mixer,'-insert_stubs/3-fun-0-',2,
                                     [{file,
                                       "c:/Development/Erlang/edsrv/_checkouts/mixer/src/mixer.erl"},
                                      {line,160}]},
                                    {lists,foldr,3,
                                     [{file,"lists.erl"},{line,1280}]},
                                    {mixer,insert_stubs,3,
                                     [{file,
                                       "c:/Development/Erlang/edsrv/_checkouts/mixer/src/mixer.erl"},
                                      {line,161}]},
                                    {mixer,parse_transform,2,
                                     [{file,
                                       "c:/Development/Erlang/edsrv/_checkouts/mixer/src/mixer.erl"},
                                      {line,43}]},
                                    {compile,foldl_transform,3,
                                     [{file,"compile.erl"},{line,1145}]},
                                    {compile,fold_comp,4,
                                     [{file,"compile.erl"},{line,416}]},
                                    {compile,internal_comp,5,
                                     [{file,"compile.erl"},{line,400}]},
                                    {compile,'-internal_fun/2-anonymous-0-',
                                     2,
                                     [{file,"compile.erl"},{line,229}]}]}

Possible Solution

The following code (inside NEW below) resolves the issue

strip_eof([], Accum) ->
    lists:reverse(Accum);
%% NEW
strip_eof([{eof, {EOF, _COL}}|T], Accum) ->
    {EOF, lists:reverse(Accum) ++ T};
%% /NEW
strip_eof([{eof, EOF}|T], Accum) ->
    {EOF, lists:reverse(Accum) ++ T};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions