Skip to content

Commit

Permalink
Fix self-check errors in gradualizer_lib:pick_value/2
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed Mar 2, 2023
1 parent 6679dd6 commit be5306f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/gradualizer_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ pick_value(?type(binary, _), _Env) ->
%% The ?type(range) is a different case because the type range
%% ..information is not encoded as an abstract_type()
%% i.e. {type, Anno, range, [{integer, Anno2, Low}, {integer, Anno3, High}]}
pick_value(?type(range, [{_TagLo, _, neg_inf}, Hi = {_TagHi, _, _Hi}]), _Env) ->
pick_value(?type(range, [{_TagLo, _, neg_inf}, Hi = {_TagHi, _, _Hi}]), Env) ->
%% pick_value(Hi, Env);
Hi;
pick_value(?type(range, [Lo = {_TagLo, _, _Lo}, {_TagHi, _, _Hi}]), _Env) ->
pick_value_range_bound(Hi, Env);
pick_value(?type(range, [Lo = {_TagLo, _, _Lo}, {_TagHi, _, _Hi}]), Env) ->
%% pick_value(Lo, Env).
Lo;
pick_value_range_bound(Lo, Env);
pick_value(?remote_type(_, _, _) = Type, Env) ->
pick_remote_or_user_type_value(Type, Env);
pick_value(?user_type(_, _, _) = Type, Env) ->
Expand All @@ -245,6 +245,17 @@ pick_remote_or_user_type_value(Type, Env) ->
throw({undef, Kind, Anno, {Name, length(Args)}})
end.

-spec pick_value_range_bound(any(), typechecker:env()) -> gradualizer_type:abstract_expr().
pick_value_range_bound({integer, _, neg_inf}, _Env) ->
{atom, erl_anno:new(0), neg_inf};
pick_value_range_bound({integer, _, pos_inf}, _Env) ->
{atom, erl_anno:new(0), pos_inf};
pick_value_range_bound({integer, L, I}, _Env) when I < 0 ->
{op, L, '-', {integer, L, -I}};
pick_value_range_bound({integer, L, I}, _Env) ->
I = ?assert_type(I, non_neg_integer()),
{integer, L, I}.

%% ------------------------------------------------
%% Functions for working with abstract syntax trees
%% ------------------------------------------------
Expand Down

0 comments on commit be5306f

Please sign in to comment.