summaryrefslogtreecommitdiff
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2023-05-04 13:14:39 +0200
committerGitHub <noreply@github.com>2023-05-04 13:14:39 +0200
commitc2f02cc939f19ebd76f4c4a07b8b3e4b9b3c7cd0 (patch)
tree3c684c22a2135f4ff201160ad74a23ce547b0555 /lib/compiler/src
parent24211242b21aa8ff6d2691c898c162f9bd3d19d1 (diff)
parent132fa15545d9f49ebcaa4abf99f3754df6efa868 (diff)
downloaderlang-c2f02cc939f19ebd76f4c4a07b8b3e4b9b3c7cd0.tar.gz
Merge pull request #7201 from bjorng/bjorn/compiler/fix-beam_call_types/GH-7197
Eliminate crash in beam_ssa_type
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_call_types.erl39
1 files changed, 24 insertions, 15 deletions
diff --git a/lib/compiler/src/beam_call_types.erl b/lib/compiler/src/beam_call_types.erl
index 697566cecb..4324080098 100644
--- a/lib/compiler/src/beam_call_types.erl
+++ b/lib/compiler/src/beam_call_types.erl
@@ -364,21 +364,30 @@ types(erlang, is_boolean, [Type]) ->
end;
types(erlang, is_float, [Type]) ->
sub_unsafe_type_test(Type, #t_float{});
-types(erlang, is_function, [Type, #t_integer{elements={Arity,Arity}}])
- when is_integer(Arity) ->
- RetType =
- if
- Arity < 0 ->
- none;
- 0 =< Arity, Arity =< ?MAX_FUNC_ARGS ->
- case meet(Type, #t_fun{arity=Arity}) of
- Type -> #t_atom{elements=[true]};
- none -> #t_atom{elements=[false]};
- _ -> beam_types:make_boolean()
- end;
- Arity > ?MAX_FUNC_ARGS ->
- #t_atom{elements=[false]}
- end,
+types(erlang, is_function, [Type, ArityType]) ->
+ RetType = case meet(ArityType, #t_integer{}) of
+ none ->
+ none;
+ #t_integer{elements={Arity,Arity}}
+ when is_integer(Arity) ->
+ if
+ Arity < 0 ->
+ none;
+ 0 =< Arity, Arity =< ?MAX_FUNC_ARGS ->
+ case meet(Type, #t_fun{arity=Arity}) of
+ Type -> #t_atom{elements=[true]};
+ none -> #t_atom{elements=[false]};
+ _ -> beam_types:make_boolean()
+ end;
+ Arity > ?MAX_FUNC_ARGS ->
+ #t_atom{elements=[false]}
+ end;
+ #t_integer{} ->
+ case meet(Type, #t_fun{}) of
+ none -> #t_atom{elements=[false]};
+ _ -> beam_types:make_boolean()
+ end
+ end,
sub_unsafe(RetType, [any, any]);
types(erlang, is_function, [Type]) ->
sub_unsafe_type_test(Type, #t_fun{});