Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
reganheath opened this issue May 30, 2021 · 0 comments
Open

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

reganheath opened this issue May 30, 2021 · 0 comments

Comments

@reganheath
Copy link

reganheath commented May 30, 2021

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};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant