Skip to content

Commit

Permalink
Use lists:usort/1 instead of lists:uniq/1 on OTP < 25
Browse files Browse the repository at this point in the history
lists:uniq/1 was introduced in OTP 25.
  • Loading branch information
xxdavid committed May 3, 2024
1 parent 7cd2522 commit 1ea043c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/constraints.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ do_combine(Cs1, Cs2, Env) ->

-spec variables(t()) -> [var()].
variables(#constraints{ upper_bounds = UBounds, lower_bounds = LBounds }) ->
lists:uniq(maps:keys(UBounds) ++ maps:keys(LBounds)).
gradualizer_lib:uniq(maps:keys(UBounds) ++ maps:keys(LBounds)).


%% Checks that all lower bounds are subtypes of respective upper bounds.
Expand Down
9 changes: 8 additions & 1 deletion src/gradualizer_lib.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% @private
-module(gradualizer_lib).

-export([merge_with/3, top_sort/1, get_type_definition/3,
-export([merge_with/3, uniq/1, top_sort/1, get_type_definition/3,
pick_values/2, fold_ast/3, get_ast_children/1,
empty_tenv/0, create_tenv/3,
remove_pos_typed_record_field/1,
Expand Down Expand Up @@ -45,6 +45,13 @@ merge_with(F, M1, M2) ->
end.
-endif.

-spec uniq([A]) -> [A].
-if(?OTP_RELEASE >= 25).
uniq(List) -> lists:uniq(List).
-else.
uniq(List) -> lists:usort(List).
-endif.

%% -- Topological sort

-type graph(Node) :: #{Node => [Node]}. %% List of incoming edges (dependencies).
Expand Down

0 comments on commit 1ea043c

Please sign in to comment.