diff options
author | Björn Gustavsson <[email protected]> | 2011-09-21 11:21:59 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-09-21 11:21:59 +0200 |
commit | b5318ec588c0927dc8610451f92888646c255020 (patch) | |
tree | 7e66ca7f6233411eb2d1a6b66b50d0c984a90daa | |
parent | 53cf0b70c705e0bf6c09f83f2ce2709d79593ce6 (diff) | |
parent | 4e3be15240c8d3f2897a994e8399684d5c8b6268 (diff) | |
download | otp-b5318ec588c0927dc8610451f92888646c255020.tar.gz otp-b5318ec588c0927dc8610451f92888646c255020.tar.bz2 otp-b5318ec588c0927dc8610451f92888646c255020.zip |
Merge branch 'bjorn/erl_bif_types/OTP-9496' into dev
* bjorn/erl_bif_types/OTP-9496:
erl_bif_types: Fix types for lists:key{search,find,member}/3
-rw-r--r-- | lib/hipe/cerl/erl_bif_types.erl | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/lib/hipe/cerl/erl_bif_types.erl b/lib/hipe/cerl/erl_bif_types.erl index 827fa79ec5..4163f2dae2 100644 --- a/lib/hipe/cerl/erl_bif_types.erl +++ b/lib/hipe/cerl/erl_bif_types.erl @@ -2329,10 +2329,7 @@ type(lists, keyfind, 3, Xs) -> case t_tuple_subtypes(Tuple) of unknown -> Ret; List -> - Keys = [type(erlang, element, 2, [Y, S]) - || S <- List], - Infs = [t_inf(Key, X) || Key <- Keys], - case all_is_none(Infs) of + case key_comparisons_fail(X, Y, List) of true -> t_atom('false'); false -> Ret end @@ -2362,9 +2359,7 @@ type(lists, keymember, 3, Xs) -> case t_tuple_subtypes(Tuple) of unknown -> t_boolean(); List -> - Keys = [type(erlang, element, 2, [Y,S]) || S <- List], - Infs = [t_inf(Key, X) || Key <- Keys], - case all_is_none(Infs) of + case key_comparisons_fail(X, Y, List) of true -> t_atom('false'); false -> t_boolean() end @@ -2394,10 +2389,7 @@ type(lists, keysearch, 3, Xs) -> case t_tuple_subtypes(Tuple) of unknown -> Ret; List -> - Keys = [type(erlang, element, 2, [Y, S]) - || S <- List], - Infs = [t_inf(Key, X) || Key <- Keys], - case all_is_none(Infs) of + case key_comparisons_fail(X, Y, List) of true -> t_atom('false'); false -> Ret end @@ -2825,9 +2817,6 @@ list_replace(1, E, [_X | Xs]) -> any_is_none_or_unit(Ts) -> lists:any(fun erl_types:t_is_none_or_unit/1, Ts). -all_is_none(Ts) -> - lists:all(fun erl_types:t_is_none/1, Ts). - check_guard([X], Test, Type) -> check_guard_single(X, Test, Type). @@ -3222,6 +3211,15 @@ type_order() -> [t_number(), t_atom(), t_reference(), t_fun(), t_port(), t_pid(), t_tuple(), t_list(), t_binary()]. +key_comparisons_fail(X0, KeyPos, TupleList) -> + X = case t_is_number(t_inf(X0, t_number())) of + false -> X0; + true -> t_number() + end, + lists:all(fun(Tuple) -> + Key = type(erlang, element, 2, [KeyPos, Tuple]), + t_is_none(t_inf(Key, X)) + end, TupleList). %%============================================================================= |