Skip to content

Commit c150876

Browse files
committed
Remove warning on non-ambiguous nullary remote call
1 parent 758da1e commit c150876

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

lib/elixir/src/elixir_expand.erl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -402,16 +402,12 @@ expand({Atom, Meta, Args}, S, E) when is_atom(Atom), is_list(Meta), is_list(Args
402402

403403
%% Remote calls
404404

405-
expand({{'.', DotMeta, [Left, Right]}, Meta, Args} = Expr, S, E)
405+
expand({{'.', DotMeta, [Left, Right]}, Meta, Args}, S, E)
406406
when (is_tuple(Left) orelse is_atom(Left)), is_atom(Right), is_list(Meta), is_list(Args) ->
407407
{ELeft, SL, EL} = expand(Left, elixir_env:prepare_write(S), E),
408-
NoParens = lists:keyfind(no_parens, 1, Meta),
409-
410-
(is_atom(ELeft) and (Args =:= []) and (NoParens =:= {no_parens, true})) andalso
411-
elixir_errors:file_warn(Meta, E, ?MODULE, {remote_nullary_no_parens, Expr}),
412408

413409
elixir_dispatch:dispatch_require(Meta, ELeft, Right, Args, S, EL, fun(AR, AF, AA) ->
414-
expand_remote(AR, DotMeta, AF, Meta, NoParens, AA, S, SL, EL)
410+
expand_remote(AR, DotMeta, AF, Meta, AA, S, SL, EL)
415411
end);
416412

417413
%% Anonymous calls
@@ -858,12 +854,13 @@ expand_local(Meta, Name, Args, _S, #{function := nil} = E) ->
858854

859855
%% Remote
860856

861-
expand_remote(Receiver, DotMeta, Right, Meta, NoParens, Args, S, SL, #{context := Context} = E) when is_atom(Receiver) or is_tuple(Receiver) ->
857+
expand_remote(Receiver, DotMeta, Right, Meta, Args, S, SL, #{context := Context} = E)
858+
when is_atom(Receiver) or is_tuple(Receiver) ->
862859
assert_no_clauses(Right, Meta, Args, E),
863860

864861
if
865862
Context =:= guard, is_tuple(Receiver) ->
866-
(NoParens /= {no_parens, true}) andalso
863+
(lists:keyfind(no_parens, 1, Meta) /= {no_parens, true}) andalso
867864
function_error(Meta, E, ?MODULE, {parens_map_lookup, Receiver, Right, guard_context(S)}),
868865

869866
{{{'.', DotMeta, [Receiver, Right]}, Meta, []}, SL, E};
@@ -881,7 +878,7 @@ expand_remote(Receiver, DotMeta, Right, Meta, NoParens, Args, S, SL, #{context :
881878
file_error(Meta, E, elixir_rewrite, Error)
882879
end
883880
end;
884-
expand_remote(Receiver, DotMeta, Right, Meta, _NoParens, Args, _, _, E) ->
881+
expand_remote(Receiver, DotMeta, Right, Meta, Args, _, _, E) ->
885882
Call = {{'.', DotMeta, [Receiver, Right]}, Meta, Args},
886883
file_error(Meta, E, ?MODULE, {invalid_call, Call}).
887884

@@ -1171,9 +1168,6 @@ assert_no_underscore_clause_in_cond(_Other, _E) ->
11711168
guard_context(#elixir_ex{prematch={_, _, {bitsize, _}}}) -> "bitstring size specifier";
11721169
guard_context(_) -> "guards".
11731170

1174-
format_error({remote_nullary_no_parens, Expr}) ->
1175-
String = 'Elixir.String':replace_suffix('Elixir.Macro':to_string(Expr), <<"()">>, <<>>),
1176-
io_lib:format("parentheses are required for function calls with no arguments, got: ~ts", [String]);
11771171
format_error(invalid_match_on_zero_float) ->
11781172
"pattern matching on 0.0 is equivalent to matching only on +0.0 from Erlang/OTP 27+. Instead you must match on +0.0 or -0.0";
11791173
format_error({useless_literal, Term}) ->

lib/elixir/test/elixir/kernel/warning_test.exs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,18 +1175,6 @@ defmodule Kernel.WarningTest do
11751175
purge(Sample)
11761176
end
11771177

1178-
test "parens on nullary remote call" do
1179-
assert_warn_eval(
1180-
[
1181-
"nofile:1:8",
1182-
"parentheses are required for function calls with no arguments, got: System.version"
1183-
],
1184-
"System.version"
1185-
)
1186-
after
1187-
purge(Sample)
1188-
end
1189-
11901178
test "parens with module attribute" do
11911179
assert_warn_eval(
11921180
[

0 commit comments

Comments
 (0)