diff options
| author | Björn Gustavsson <bjorn@erlang.org> | 2023-05-03 13:12:56 +0200 |
|---|---|---|
| committer | Björn Gustavsson <bjorn@erlang.org> | 2023-05-03 13:34:06 +0200 |
| commit | e718e07d578af2ca9726641751101e45b80cd25b (patch) | |
| tree | 001c917311a8c2e6015bca1bc8da1056d755d767 /lib/compiler/src | |
| parent | 465720cf8b6f3c14ebca43c3ce852d135b86bdbe (diff) | |
| download | erlang-e718e07d578af2ca9726641751101e45b80cd25b.tar.gz | |
Eliminate crash in beam_types
Closes #7198
Diffstat (limited to 'lib/compiler/src')
| -rw-r--r-- | lib/compiler/src/beam_types.erl | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/compiler/src/beam_types.erl b/lib/compiler/src/beam_types.erl index b668251f79..c3bf7c8fae 100644 --- a/lib/compiler/src/beam_types.erl +++ b/lib/compiler/src/beam_types.erl @@ -1179,14 +1179,13 @@ float_from_range(none) -> none; float_from_range(any) -> #t_float{}; -float_from_range({'-inf','+inf'}) -> - #t_float{}; -float_from_range({'-inf',Max}) -> - make_float_range('-inf', safe_float(Max)); -float_from_range({Min,'+inf'}) -> - make_float_range(safe_float(Min), '+inf'); -float_from_range({Min,Max}) -> - make_float_range(safe_float(Min), safe_float(Max)). +float_from_range({Min0,Max0}) -> + case {safe_float(Min0),safe_float(Max0)} of + {'-inf','+inf'} -> + #t_float{}; + {Min,Max} -> + #t_float{elements={Min,Max}} + end. safe_float(N) when is_number(N) -> try @@ -1194,12 +1193,9 @@ safe_float(N) when is_number(N) -> catch error:_ when N < 0 -> '-inf'; error:_ when N > 0 -> '+inf' - end. - -make_float_range('-inf', '+inf') -> - #t_float{}; -make_float_range(Min, Max) -> - #t_float{elements={Min, Max}}. + end; +safe_float('-inf'=NegInf) -> NegInf; +safe_float('+inf'=PosInf) -> PosInf. integer_from_range(none) -> none; |
