Skip to content

Commit

Permalink
Handle annotations and locations better
Browse files Browse the repository at this point in the history
This PR is one of several affecting repositories on Github. It
aims at fixing bad use of annotations (see erl_anno(3)). The
following remarks are common to all PR:s.

Typically the second element of abstract code tuples is assumed
to be an integer, which is no longer always true. For instance,
the parse transform implementing QLC tables (see qlc(3)) returns
code where some annotations are marked as `generated'. Such an
annotation is a list, not an integer (it used to be a negative
integer).

As of Erlang/OTP 24.0, the location can be a tuple {Line, Column},
which is another reason to handle annotations properly.
  • Loading branch information
uabboli committed Jan 13, 2021
1 parent bf146d8 commit 8d3bccc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lyet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
-define(ERROR(R, T, F, I),
begin
rpt_error(R, T, F, I),
throw({error,erl_syntax:get_pos(
proplists:get_value(form,I)),{unknown,R}})
throw({error,erl_anno:location(get_pos(
proplists:get_value(form,I))),{unknown,R}})
end).

-import(erl_syntax, [clause/3,
Expand Down Expand Up @@ -62,14 +62,14 @@ parse_transform(Forms, Options) ->
[Expr|Assignments] = lists:reverse(L),
lists:foldl
(fun (Assign, Acc) ->
{ match, Line, Pattern, Val } =
{ match, Anno, Pattern, Val } =
erl_syntax:revert (Assign),
{ call,
Line,
Anno,
{ 'fun',
Line,
Anno,
{ clauses,
[ { clause, Line, [ Pattern ], [], [ Acc ] } ]
[ { clause, Anno, [ Pattern ], [], [ Acc ] } ]
}
},
[ Val ]
Expand Down

0 comments on commit 8d3bccc

Please sign in to comment.