Skip to content

Commit

Permalink
Adapt codegen:exprs substitutions to Erlang 24 (#50)
Browse files Browse the repository at this point in the history
Substitutions in codegen:exprs/1 were expecting
locations to be integers.  But with Erlang 24,
these are {Line, Column} instead. Handle both.
  • Loading branch information
tomas-abrahamsson committed Jun 2, 2021
1 parent 56f5c6c commit 64b9b77
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/parse_trans_codegen.erl
Expand Up @@ -376,23 +376,32 @@ abstract(ClauseForms) ->

substitute({tuple,L0,
[{atom,_,tuple},
{integer,_,L},
Loc,
{cons,_,
{tuple,_,[{atom,_,atom},{integer,_,_},{atom,_,'$var'}]},
{tuple,_,[{atom,_,atom},_LocA,{atom,_,'$var'}]},
{cons,_,
{tuple,_,[{atom,_,var},{integer,_,_},{atom,_,V}]},
{nil,_}}}]}) ->
{tuple,_,[{atom,_,var},_LocB,{atom,_,V}]},
{nil,_}}}]}) when element(1, Loc) == tuple; % Erlang 24+
element(1, Loc) == integer ->
AbstConcreteLoc =
case Loc of
{integer, _, L} ->
{integer, L0, L};
{tuple, _, [{integer, _, L}, {integer, _, C}]} ->
{tuple, L0, [{integer, L0, L}, {integer, L0, C}]}
end,
{call, L0, {remote,L0,{atom,L0,erl_parse},
{atom,L0,abstract}},
[{var, L0, V}, {integer, L0, L}]};
substitute({tuple,L0,
[{var, L0, V}, AbstConcreteLoc]};
substitute({tuple,L0, % Erlang 24: {Line,Col}
[{atom,_,tuple},
{integer,_,_},
Loc,
{cons,_,
{tuple,_,[{atom,_,atom},{integer,_,_},{atom,_,'$form'}]},
{tuple,_,[{atom,_,atom},_LocA,{atom,_,'$form'}]},
{cons,_,
{tuple,_,[{atom,_,var},{integer,_,_},{atom,_,F}]},
{nil,_}}}]}) ->
{tuple,_,[{atom,_,var},_LocB,{atom,_,F}]},
{nil,_}}}]}) when element(1, Loc) == tuple; % Erlang 24+
element(1, Loc) == integer ->
{var, L0, F};
substitute([]) ->
[];
Expand Down

0 comments on commit 64b9b77

Please sign in to comment.