summaryrefslogtreecommitdiff
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2023-05-04 13:15:03 +0200
committerGitHub <noreply@github.com>2023-05-04 13:15:03 +0200
commit196a9f2a03921d590a9e21ed4302a58ec63f88be (patch)
tree6cc808022bc4725c654168c2de17452f641c6812 /lib/compiler/src
parentc2f02cc939f19ebd76f4c4a07b8b3e4b9b3c7cd0 (diff)
parente718e07d578af2ca9726641751101e45b80cd25b (diff)
downloaderlang-196a9f2a03921d590a9e21ed4302a58ec63f88be.tar.gz
Merge pull request #7200 from bjorng/bjorn/compiler/fix-beam_types-crash/GH-7198
Eliminate crash in beam_types
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_types.erl24
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;