aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-02-19 08:53:41 +0100
committerJohn Högberg <[email protected]>2019-02-20 18:40:24 +0100
commita7dbb9cea6ade38a171f437489c35537a84789cf (patch)
tree3596e774f04711b22e307130006bc88e4082e383
parent2942df1a76442328d5ec7a13daab3b2983d8e48e (diff)
downloadotp-a7dbb9cea6ade38a171f437489c35537a84789cf.tar.gz
otp-a7dbb9cea6ade38a171f437489c35537a84789cf.tar.bz2
otp-a7dbb9cea6ade38a171f437489c35537a84789cf.zip
beam_validator: Get rid of the last uses of set_aliased_type
Granted, it's replaced with a thin wrapper, but it'll simplify migration to the new type format.
-rw-r--r--lib/compiler/src/beam_validator.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl
index 3403a7232a..42ffb04b98 100644
--- a/lib/compiler/src/beam_validator.erl
+++ b/lib/compiler/src/beam_validator.erl
@@ -699,9 +699,13 @@ valfun_4({set_tuple_element,Src,Tuple,N}, Vst) ->
I = N + 1,
assert_not_fragile(Src, Vst),
assert_type({tuple_element,I}, Tuple, Vst),
+ %% Manually update the tuple type; we can't rely on the ordinary update
+ %% helpers as we must support overwriting (rather than just widening or
+ %% narrowing) known elements, and we can't use extract_term either since
+ %% the source tuple may be aliased.
{tuple, Sz, Es0} = get_term_type(Tuple, Vst),
Es = set_element_type(I, get_term_type(Src, Vst), Es0),
- set_aliased_type({tuple, Sz, Es}, Tuple, Vst);
+ override_type({tuple, Sz, Es}, Tuple, Vst);
%% Match instructions.
valfun_4({select_val,Src,{f,Fail},{list,Choices}}, Vst0) ->
assert_term(Src, Vst0),
@@ -974,9 +978,11 @@ validate_bs_start_match(Fail, Live, Type, Src, Dst, Vst) ->
%% #ms{} can represent either a match context or a term, so we have to mark
%% the source as a term if it fails, and retain the incoming type if it
%% succeeds (match context or not).
+ %%
+ %% The override_type hack is only needed until we get proper union types.
complex_test(Fail,
fun(FailVst) ->
- set_aliased_type(term, Src, FailVst)
+ override_type(term, Src, FailVst)
end,
fun(SuccVst0) ->
SuccVst = prune_x_regs(Live, SuccVst0),