@@ -401,14 +401,13 @@ expand({{'.', DotMeta, [Left, Right]}, Meta, Args}, E)
401
401
when (is_tuple (Left ) orelse is_atom (Left )), is_atom (Right ), is_list (Meta ), is_list (Args ) ->
402
402
{ELeft , EL } = expand (Left , elixir_env :prepare_write (E )),
403
403
404
- % % TODO: Emit this warning on v1.11
405
- % % case is_atom(ELeft) andalso (Args == []) andalso
406
- % % (lists:keyfind(no_parens, 1, Meta) == {no_parens, true}) of
407
- % % true ->
408
- % % elixir_errors:form_warn(DotMeta, E, ?MODULE, {no_parens_nullary_remote, ELeft, Right});
409
- % % false ->
410
- % % ok
411
- % % end,
404
+ case is_atom (ELeft ) andalso (Args == []) andalso
405
+ (lists :keyfind (no_parens , 1 , Meta ) == {no_parens , true }) of
406
+ true ->
407
+ elixir_errors :form_warn (DotMeta , E , ? MODULE , {no_parens_nullary_remote , ELeft , Right });
408
+ false ->
409
+ ok
410
+ end ,
412
411
413
412
elixir_dispatch :dispatch_require (Meta , ELeft , Right , Args , EL , fun (AR , AF , AA ) ->
414
413
expand_remote (AR , DotMeta , AF , Meta , AA , E , EL )
@@ -520,6 +519,7 @@ expand_fn_capture(Meta, Arg, E) ->
520
519
is_atom (Remote ) andalso
521
520
elixir_env :trace ({remote_function , Meta , Remote , Fun , Arity }, E ),
522
521
AttachedMeta = attach_context_module (Remote , Meta , E ),
522
+ handle_capture_possible_warning (Meta , Arg , E , Arity , Remote , Fun ),
523
523
{{'&' , AttachedMeta , [{'/' , [], [{{'.' , [], [Remote , Fun ]}, [], []}, Arity ]}]}, EE };
524
524
{{local , Fun , Arity }, #{function := nil }} ->
525
525
form_error (Meta , E , ? MODULE , {undefined_local_capture , Fun , Arity });
@@ -529,6 +529,16 @@ expand_fn_capture(Meta, Arg, E) ->
529
529
expand (Expr , EE )
530
530
end .
531
531
532
+ handle_capture_possible_warning (Meta , {_ , _ , [{_ , KeyList , _ }, _ ]}, E , 0 , Remote , Fun ) ->
533
+ case (lists :keyfind (no_parens , 1 , KeyList ) /= {no_parens , true }) of
534
+ true ->
535
+ elixir_errors :form_warn (Meta , E , ? MODULE , {parens_remote_capture , Remote , Fun });
536
+
537
+ false -> ok
538
+ end ;
539
+
540
+ handle_capture_possible_warning (_ , _ , _ , _ , _ , _ ) -> ok .
541
+
532
542
expand_list ([{'|' , Meta , [_ , _ ] = Args }], Fun , Acc , List ) ->
533
543
{EArgs , EAcc } = lists :mapfoldl (Fun , Acc , Args ),
534
544
expand_list ([], Fun , EAcc , [{'|' , Meta , EArgs } | List ]);
@@ -1270,9 +1280,13 @@ format_error({unknown_variable, Name}) ->
1270
1280
io_lib :format (" variable \" ~ts \" does not exist and is being expanded to \" ~ts ()\" ,"
1271
1281
" please use parentheses to remove the ambiguity or change the variable name" , [Name , Name ]);
1272
1282
format_error ({no_parens_nullary_remote , Remote , Fun }) ->
1273
- io_lib :format (" missing parenthesis on call to ~ts .~ts /0. "
1274
- " parenthesis are always required on function calls without arguments" ,
1283
+ io_lib :format (" missing parentheses on call to ~ts .~ts /0. "
1284
+ " Parentheses are always required on function calls without arguments" ,
1275
1285
[elixir_aliases :inspect (Remote ), Fun ]);
1286
+ format_error ({parens_remote_capture , Remote , Fun }) ->
1287
+ io_lib :format (" extra parentheses on a remote function capture &~ts .~ts ()/0 have been "
1288
+ " deprecated. Please remove the parentheses: &~ts .~ts /0" ,
1289
+ [elixir_aliases :inspect (Remote ), Fun , elixir_aliases :inspect (Remote ), Fun ]);
1276
1290
format_error ({parens_map_lookup_guard , Map , Field }) ->
1277
1291
io_lib :format (" cannot invoke remote function in guard. "
1278
1292
" If you want to do a map lookup instead, please remove parens from ~ts .~ts ()" ,
0 commit comments