@@ -396,12 +396,16 @@ expand({Atom, Meta, Args}, S, E) when is_atom(Atom), is_list(Meta), is_list(Args
396
396
397
397
% % Remote calls
398
398
399
- expand ({{'.' , DotMeta , [Left , Right ]}, Meta , Args }, S , E )
399
+ expand ({{'.' , DotMeta , [Left , Right ]}, Meta , Args } = Expr , S , E )
400
400
when (is_tuple (Left ) orelse is_atom (Left )), is_atom (Right ), is_list (Meta ), is_list (Args ) ->
401
401
{ELeft , SL , EL } = expand (Left , elixir_env :prepare_write (S ), E ),
402
+ NoParens = lists :keyfind (no_parens , 1 , Meta ),
403
+
404
+ (is_atom (ELeft ) and (Args =:= []) and (NoParens =:= {no_parens , true })) andalso
405
+ elixir_errors :file_warn (Meta , E , ? MODULE , {remote_nullary_no_parens , Expr }),
402
406
403
407
elixir_dispatch :dispatch_require (Meta , ELeft , Right , Args , S , EL , fun (AR , AF , AA ) ->
404
- expand_remote (AR , DotMeta , AF , Meta , AA , S , SL , EL )
408
+ expand_remote (AR , DotMeta , AF , Meta , NoParens , AA , S , SL , EL )
405
409
end );
406
410
407
411
% % Anonymous calls
@@ -844,17 +848,17 @@ expand_local(Meta, Name, Args, _S, #{function := nil} = E) ->
844
848
845
849
% % Remote
846
850
847
- expand_remote (Receiver , DotMeta , Right , Meta , Args , S , SL , #{context := Context } = E ) when is_atom (Receiver ) or is_tuple (Receiver ) ->
851
+ expand_remote (Receiver , DotMeta , Right , Meta , NoParens , Args , S , SL , #{context := Context } = E ) when is_atom (Receiver ) or is_tuple (Receiver ) ->
848
852
assert_no_clauses (Right , Meta , Args , E ),
849
853
850
- case { Context , lists : keyfind ( no_parens , 1 , Meta )} of
851
- { guard , NoParens } when is_tuple (Receiver ) ->
854
+ if
855
+ Context =:= guard , is_tuple (Receiver ) ->
852
856
(NoParens /= {no_parens , true }) andalso
853
857
function_error (Meta , E , ? MODULE , {parens_map_lookup , Receiver , Right , guard_context (S )}),
854
858
855
859
{{{'.' , DotMeta , [Receiver , Right ]}, Meta , []}, SL , E };
856
860
857
- _ ->
861
+ true ->
858
862
AttachedDotMeta = attach_context_module (Receiver , DotMeta , E ),
859
863
860
864
is_atom (Receiver ) andalso
@@ -871,7 +875,7 @@ expand_remote(Receiver, DotMeta, Right, Meta, Args, S, SL, #{context := Context}
871
875
file_error (Meta , E , elixir_rewrite , Error )
872
876
end
873
877
end ;
874
- expand_remote (Receiver , DotMeta , Right , Meta , Args , _ , _ , E ) ->
878
+ expand_remote (Receiver , DotMeta , Right , Meta , _NoParens , Args , _ , _ , E ) ->
875
879
Call = {{'.' , DotMeta , [Receiver , Right ]}, Meta , Args },
876
880
file_error (Meta , E , ? MODULE , {invalid_call , Call }).
877
881
@@ -1159,6 +1163,9 @@ assert_no_underscore_clause_in_cond(_Other, _E) ->
1159
1163
guard_context (# elixir_ex {prematch = {_ , _ , {bitsize , _ }}}) -> " bitstring size specifier" ;
1160
1164
guard_context (_ ) -> " guards" .
1161
1165
1166
+ format_error ({remote_nullary_no_parens , Expr }) ->
1167
+ String = 'Elixir.String' :replace_suffix ('Elixir.Macro' :to_string (Expr ), <<" ()" >>, <<>>),
1168
+ io_lib :format (" parentheses are required for function calls with no arguments, got: ~t s" , [String ]);
1162
1169
format_error ({useless_literal , Term }) ->
1163
1170
io_lib :format (" code block contains unused literal ~t s "
1164
1171
" (remove the literal or assign it to _ to avoid warnings)" ,
0 commit comments