aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-02-26 09:11:15 +0100
committerJohn Högberg <[email protected]>2019-02-27 11:57:24 +0100
commit11bc38e0a5f8028be4bad1345a788656346df2e2 (patch)
tree0a0ea5a71264848d27317987ab21f77029273875 /lib/compiler/src
parentbd8b59751bf91d1d70aba2a77fe206e231bd27e6 (diff)
downloadotp-11bc38e0a5f8028be4bad1345a788656346df2e2.tar.gz
otp-11bc38e0a5f8028be4bad1345a788656346df2e2.tar.bz2
otp-11bc38e0a5f8028be4bad1345a788656346df2e2.zip
beam_validator: Simplify get_element_type
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/beam_validator.erl8
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index 1a1afab294..0d8ab3739c 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -620,10 +620,7 @@ valfun_4({make_fun2,_,_,_,Live}, Vst) ->
%% Other BIFs
valfun_4({bif,element,{f,Fail},[Pos,Tuple],Dst}, Vst0) ->
PosType = get_durable_term_type(Pos, Vst0),
- ElementType = case PosType of
- {integer,I} -> get_element_type({integer,I}, Tuple, Vst0);
- _ -> term
- end,
+ ElementType = get_element_type(PosType, Tuple, Vst0),
InferredType = {tuple,[get_tuple_size(PosType)],#{}},
Vst1 = branch_state(Fail, Vst0),
Vst = update_type(fun meet/2, InferredType, Tuple, Vst1),
@@ -1889,8 +1886,7 @@ assert_type(Needed, Actual) ->
get_element_type(Key, Src, Vst) ->
get_element_type_1(Key, get_durable_term_type(Src, Vst)).
-get_element_type_1(Key, {tuple,Sz,Es}) ->
- {integer,Index} = Key, %Assertion.
+get_element_type_1({integer,Index}=Key, {tuple,Sz,Es}) ->
case Es of
#{ Key := Type } -> Type;
#{} when Index =< Sz -> term;