Skip to content

Commit 2fbafae

Browse files
committed
improve type inference when one of the bounds is a literal
1 parent cb2e4e2 commit 2fbafae

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/compiler/src/beam_ssa_type.erl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,6 +2819,14 @@ infer_type({bif,is_integer}, [#b_var{}=Arg,
28192819
#b_literal{val=Max}], _Ts, _Ds) when Min =< Max ->
28202820
T = {Arg, beam_types:make_integer(Min, Max)},
28212821
{[T], [T]};
2822+
infer_type({bif,is_integer}, [#b_var{}=Arg,
2823+
#b_literal{val=Min},_], _Ts, _Ds) ->
2824+
T = {Arg, make_number({Min,'+inf'})},
2825+
{[T], [T]};
2826+
infer_type({bif,is_integer}, [#b_var{}=Arg,_,
2827+
#b_literal{val=Max}], _Ts, _Ds) ->
2828+
T = {Arg, make_number({'-inf',Max})},
2829+
{[T], [T]};
28222830
infer_type({bif,is_integer}, [#b_var{}=Arg, _, _], _Ts, _Ds) ->
28232831
%% We cannot subtract the type when the bounds are unknown: `Arg` may still
28242832
%% be an integer if it is not in the tested range.

0 commit comments

Comments
 (0)