From b713f93fb242e330cde1f3dcb135ec9795adccde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Wed, 19 Jun 2019 16:09:45 +0200 Subject: beam_validator: Clean up abstract/match context type handling --- lib/compiler/src/beam_types.erl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/compiler/src/beam_types.erl') 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}) -> -- cgit v1.2.3