Skip to content

Commit

Permalink
Drop no_clause_has_guards condition when checking exhaustiveness
Browse files Browse the repository at this point in the history
Since too complex guards lead to skipping a function altogether now,
this condition is redundant.
Dropping it allows exhaustiveness checking to benefit from the simple
refinements from guards that are supported.
  • Loading branch information
erszcz committed Sep 19, 2024
1 parent 8117a02 commit 701e244
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/typechecker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3998,7 +3998,6 @@ disable_exhaustiveness_check(#env{} = Env) ->
check_arg_exhaustiveness(Env, ArgTys, Clauses, RefinedArgTys) ->
case exhaustiveness_checking(Env) andalso
all_refinable(ArgTys, Env) andalso
no_clause_has_guards(Clauses) andalso
some_type_not_none(RefinedArgTys)
of
true ->
Expand All @@ -4019,10 +4018,6 @@ exhaustiveness_checking(#env{} = Env) ->
all_refinable(any, _Env) -> false;
all_refinable(Types, Env) -> lists:all(fun (Ty) -> refinable(Ty, Env) end, Types).

-spec no_clause_has_guards(_) -> boolean().
no_clause_has_guards(Clauses) ->
lists:all(fun no_guards/1, Clauses).

-spec some_type_not_none([type()]) -> boolean().
some_type_not_none(Types) when is_list(Types) ->
lists:any(fun (T) -> T =/= type(none) end, Types).
Expand Down Expand Up @@ -4564,10 +4559,6 @@ mta({user_type, Anno, Name, Args}, Env) ->
mta(Type, _Env) ->
Type.

-spec no_guards(_) -> boolean().
no_guards({clause, _, _, Guards, _}) ->
Guards == [].

%% Refines the types of bound variables using the assumption that a clause has
%% mismatched.
-spec refine_vars_by_mismatching_clause(gradualizer_type:af_clause(), venv(), env()) -> venv().
Expand Down

0 comments on commit 701e244

Please sign in to comment.