aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_types.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-06-19 16:09:45 +0200
committerJohn Högberg <[email protected]>2019-07-05 11:33:38 +0200
commitb713f93fb242e330cde1f3dcb135ec9795adccde (patch)
treef409f9e2ace4dc4590ab6a8007d58169401ccf04 /lib/compiler/src/beam_types.erl
parentdb2ab3f206934926123c3d3acd33dd7b4c6e84db (diff)
downloadotp-b713f93fb242e330cde1f3dcb135ec9795adccde.tar.gz
otp-b713f93fb242e330cde1f3dcb135ec9795adccde.tar.bz2
otp-b713f93fb242e330cde1f3dcb135ec9795adccde.zip
beam_validator: Clean up abstract/match context type handling
Diffstat (limited to 'lib/compiler/src/beam_types.erl')
-rw-r--r--lib/compiler/src/beam_types.erl12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_types.erl b/lib/compiler/src/beam_types.erl
index 752dda0d2b..4f8ba0ada5 100644
--- a/lib/compiler/src/beam_types.erl
+++ b/lib/compiler/src/beam_types.erl
@@ -171,6 +171,18 @@ meet(#t_atom{elements=[_|_]}=T, #t_atom{elements=any}) ->
T;
meet(#t_atom{elements=any}, #t_atom{elements=[_|_]}=T) ->
T;
+meet(#t_bs_context{slots=SlotCountA,valid=ValidSlotsA},
+ #t_bs_context{slots=SlotCountB,valid=ValidSlotsB}) ->
+ CommonSlotMask = (1 bsl min(SlotCountA, SlotCountB)) - 1,
+ CommonSlotsA = ValidSlotsA band CommonSlotMask,
+ CommonSlotsB = ValidSlotsB band CommonSlotMask,
+ if
+ CommonSlotsA =:= CommonSlotsB ->
+ #t_bs_context{slots=max(SlotCountA, SlotCountB),
+ valid=ValidSlotsA bor ValidSlotsB};
+ CommonSlotsA =/= CommonSlotsB ->
+ none
+ end;
meet(#t_fun{arity=any}, #t_fun{}=T) ->
T;
meet(#t_fun{}=T, #t_fun{arity=any}) ->