Skip to content

Commit d831a00

Browse files
committed
Unify clauses by extracting location and op
1 parent a09fa10 commit d831a00

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

lib/elixir/src/elixir_parser.yrl

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,9 @@ Erlang code.
663663

664664
-define(id(Token), element(1, Token)).
665665
-define(location(Token), element(2, Token)).
666-
-define(exprs(Token), element(3, Token)).
666+
-define(op(Token), element(3, Token)).
667667
-define(meta(Node), element(2, Node)).
668+
-define(exprs(Node), element(3, Node)).
668669
-define(rearrange_uop(Op), (Op == 'not' orelse Op == '!')).
669670

670671
-compile({inline, meta_from_token/1, meta_from_location/1, is_eol/1}).
@@ -1295,20 +1296,12 @@ warn_pipe(_Token, _) ->
12951296
ok.
12961297

12971298
%% TODO: Make this an error on v2.0
1298-
warn_no_parens_after_do_op({{in_op, Location, Op, _InLocation}, _}) ->
1299-
{Line, _, _} = Location,
1299+
warn_no_parens_after_do_op({Token, _}) ->
1300+
{Line, _, _} = ?location(Token),
13001301

13011302
warn(
13021303
Line,
1303-
"missing parentheses on expression following operator \"" ++ atom_to_list(Op) ++ "\", "
1304-
"you must add parentheses to avoid ambiguities"
1305-
);
1306-
warn_no_parens_after_do_op({{_Type, Location, Op}, _}) ->
1307-
{Line, _, _} = Location,
1308-
1309-
warn(
1310-
Line,
1311-
"missing parentheses on expression following operator \"" ++ atom_to_list(Op) ++ "\", "
1304+
"missing parentheses on expression following operator \"" ++ atom_to_list(?op(Token)) ++ "\", "
13121305
"you must add parentheses to avoid ambiguities"
13131306
).
13141307

0 commit comments

Comments
 (0)