Skip to content

Commit a52133f

Browse files
committed
Remove more checks that can now be performed by the type system
1 parent ed67d6b commit a52133f

File tree

3 files changed

+0
-59
lines changed

3 files changed

+0
-59
lines changed

lib/elixir/src/elixir_expand.erl

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ expand({{'.', DotMeta, [Left, Right]}, Meta, Args}, S, E)
452452
expand({{'.', DotMeta, [Expr]}, Meta, Args}, S, E) when is_list(Args) ->
453453
assert_no_match_or_guard_scope(Meta, "anonymous call", S, E),
454454
{[EExpr | EArgs], SA, EA} = expand_args([Expr | Args], S, E),
455-
is_atom(EExpr) andalso function_error(Meta, E, ?MODULE, {invalid_function_call, EExpr}),
456455
{{{'.', DotMeta, [EExpr]}, Meta, EArgs}, SA, EA};
457456

458457
%% Invalid calls
@@ -887,7 +886,6 @@ expand_remote(Receiver, DotMeta, Right, Meta, Args, S, SL, #{context := Context}
887886

888887
case rewrite(Context, Receiver, DotMeta, Right, AttachedMeta, EArgs, S) of
889888
{ok, Rewritten} ->
890-
maybe_warn_comparison(Rewritten, Args, E),
891889
{Rewritten, elixir_env:close_write(SA, S), EA};
892890

893891
{error, Error} ->
@@ -914,32 +912,6 @@ rewrite(guard, Receiver, DotMeta, Right, Meta, EArgs, S) ->
914912
rewrite(_, Receiver, DotMeta, Right, Meta, EArgs, _S) ->
915913
{ok, elixir_rewrite:rewrite(Receiver, DotMeta, Right, Meta, EArgs)}.
916914

917-
maybe_warn_comparison({{'.', _, [erlang, Op]}, Meta, [ELeft, ERight]}, [Left, Right], E)
918-
when Op =:= '>'; Op =:= '<'; Op =:= '=<'; Op =:= '>='; Op =:= min; Op =:= max ->
919-
920-
case is_nested_comparison(Op, ELeft, ERight, Left, Right) of
921-
false -> ok;
922-
CompExpr ->
923-
elixir_errors:file_warn(Meta, E, ?MODULE, {nested_comparison, CompExpr})
924-
end;
925-
maybe_warn_comparison(_, _, _) ->
926-
ok.
927-
928-
is_nested_comparison(Op, ELeft, ERight, Left, Right) ->
929-
NestedExpr = {elixir_utils:erlang_comparison_op_to_elixir(Op), [], [Left, Right]},
930-
case is_comparison_expression(ELeft) of
931-
true ->
932-
NestedExpr;
933-
false ->
934-
case is_comparison_expression(ERight) of
935-
true -> NestedExpr;
936-
false -> false
937-
end
938-
end.
939-
is_comparison_expression({{'.',_,[erlang, Op]},_,_})
940-
when Op =:= '>'; Op =:= '<'; Op =:= '=<'; Op =:= '>=' -> true;
941-
is_comparison_expression(_Other) -> false.
942-
943915
%% Lexical helpers
944916

945917
expand_opts(Meta, Kind, Allowed, Opts, S, E) ->
@@ -1241,8 +1213,6 @@ format_error({invalid_clauses, Name}) ->
12411213
"the function \"~ts\" cannot handle clauses with the -> operator because it is not a macro. "
12421214
"Please make sure you are invoking the proper name and that it is a macro",
12431215
io_lib:format(Message, [Name]);
1244-
format_error({invalid_function_call, Expr}) ->
1245-
io_lib:format("invalid function call :~ts.()", [Expr]);
12461216
format_error({invalid_call, Call}) ->
12471217
io_lib:format("invalid call ~ts", ['Elixir.Macro':to_string(Call)]);
12481218
format_error({invalid_quoted_expr, Expr}) ->

lib/elixir/test/elixir/kernel/expansion_test.exs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -654,12 +654,6 @@ defmodule Kernel.ExpansionTest do
654654
test "expands base and args" do
655655
assert expand(quote(do: a.(b))) == quote(do: a().(b()))
656656
end
657-
658-
test "raises on atom base" do
659-
assert_compile_error(~r"invalid function call :foo.()", fn ->
660-
expand(quote(do: :foo.(a)))
661-
end)
662-
end
663657
end
664658

665659
describe "remotes" do

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,29 +2147,6 @@ defmodule Kernel.WarningTest do
21472147
purge(Sample)
21482148
end
21492149

2150-
test "nested comparison operators" do
2151-
message =
2152-
capture_compile("""
2153-
1 < 3 < 5
2154-
""")
2155-
2156-
assert message =~ "nofile:1:8\n"
2157-
assert message =~ "Elixir does not support nested comparisons"
2158-
assert message =~ "1 < 3 < 5"
2159-
2160-
message =
2161-
capture_compile("""
2162-
x = 5
2163-
y = 7
2164-
1 < x < y < 10
2165-
""")
2166-
2167-
assert message =~ "Elixir does not support nested comparisons"
2168-
assert message =~ "1 < x < y < 10"
2169-
assert message =~ "nofile:3:9\n"
2170-
assert message =~ "nofile:3:13\n"
2171-
end
2172-
21732150
test "def warns if only clause is else" do
21742151
assert_warn_compile(
21752152
["nofile:2:7\n", "\"else\" shouldn't be used as the only clause in \"def\""],

0 commit comments

Comments
 (0)