@@ -640,7 +640,6 @@ map -> struct_op struct_expr eol map_args : {'%', meta_from_token('$1'), ['$2',
640
640
641
641
Erlang code .
642
642
643
- -define (file (), get (elixir_parser_file )).
644
643
-define (columns (), get (elixir_parser_columns )).
645
644
-define (token_metadata (), get (elixir_token_metadata )).
646
645
@@ -729,10 +728,12 @@ build_op(AST, {_Kind, Location, '//'}, Right) ->
729
728
730
729
build_op ({UOp , _ , [Left ]}, {_Kind , {Line , Column , _ } = Location , 'in' }, Right ) when ? rearrange_uop (UOp ) ->
731
730
% % TODO: Remove "not left in right" rearrangement on v2.0
732
- elixir_errors :erl_warn ({Line , Column }, ? file (),
731
+ warn (
732
+ {Line , Column },
733
733
" \" not expr1 in expr2\" is deprecated. "
734
734
" Instead use \" expr1 not in expr2\" if you require Elixir v1.5+, "
735
- " or \" not(expr1 in expr2)\" if you have to support earlier Elixir versions" ),
735
+ " or \" not(expr1 in expr2)\" if you have to support earlier Elixir versions"
736
+ ),
736
737
Meta = meta_from_location (Location ),
737
738
{UOp , Meta , [{'in' , Meta , [Left , Right ]}]};
738
739
@@ -1169,21 +1170,22 @@ error_invalid_kw_identifier({_, Location, KW}) ->
1169
1170
1170
1171
% % TODO: Make this an error on v2.0
1171
1172
warn_trailing_comma ({',' , {Line , Column , _ }}) ->
1172
- elixir_errors :erl_warn ({Line , Column }, ? file (),
1173
- " trailing commas are not allowed inside function/macro call arguments"
1174
- ).
1173
+ warn ({Line , Column }, " trailing commas are not allowed inside function/macro call arguments" ).
1175
1174
1176
1175
% % TODO: Make this an error on v2.0
1177
1176
warn_empty_paren ({_ , {Line , Column , _ }}) ->
1178
- elixir_errors :erl_warn ({Line , Column }, ? file (),
1177
+ warn (
1178
+ {Line , Column },
1179
1179
" invalid expression (). "
1180
1180
" If you want to invoke or define a function, make sure there are "
1181
1181
" no spaces between the function name and its arguments. If you wanted "
1182
- " to pass an empty block or code, pass a value instead, such as a nil or an atom" ).
1182
+ " to pass an empty block or code, pass a value instead, such as a nil or an atom"
1183
+ ).
1183
1184
1184
1185
% % TODO: Make this an error on v2.0
1185
1186
warn_pipe ({arrow_op , {Line , Column , _ }, Op }, {_ , [_ | _ ], [_ | _ ]}) ->
1186
- elixir_errors :erl_warn ({Line , Column }, ? file (),
1187
+ warn (
1188
+ {Line , Column },
1187
1189
io_lib :format (
1188
1190
" parentheses are required when piping into a function call. For example:\n\n "
1189
1191
" foo 1 ~ts bar 2 ~ts baz 3\n\n "
@@ -1197,6 +1199,14 @@ warn_pipe(_Token, _) ->
1197
1199
ok .
1198
1200
1199
1201
warn_empty_stab_clause ({stab_op , {Line , Column , _ }, '->' }) ->
1200
- elixir_errors :erl_warn ({Line , Column }, ? file (),
1202
+ warn (
1203
+ {Line , Column },
1201
1204
" an expression is always required on the right side of ->. "
1202
- " Please provide a value after ->" ).
1205
+ " Please provide a value after ->"
1206
+ ).
1207
+
1208
+ warn (LineColumn , Message ) ->
1209
+ case get (elixir_parser_warning_file ) of
1210
+ nil -> ok ;
1211
+ File -> elixir_errors :erl_warn (LineColumn , File , Message )
1212
+ end .
0 commit comments