From 1ea043c40fbeccea1447eb930aac532f32ecafa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Pavl=C3=ADk?= Date: Fri, 3 May 2024 18:25:44 +0200 Subject: [PATCH] Use lists:usort/1 instead of lists:uniq/1 on OTP < 25 lists:uniq/1 was introduced in OTP 25. --- src/constraints.erl | 2 +- src/gradualizer_lib.erl | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/constraints.erl b/src/constraints.erl index 699de889..1c23a17b 100644 --- a/src/constraints.erl +++ b/src/constraints.erl @@ -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. diff --git a/src/gradualizer_lib.erl b/src/gradualizer_lib.erl index 883a3dfb..6be522eb 100644 --- a/src/gradualizer_lib.erl +++ b/src/gradualizer_lib.erl @@ -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, @@ -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).