Skip to content

Commit

Permalink
Merge branch 'john/compiler/validator-container-type-subtraction-pt3/…
Browse files Browse the repository at this point in the history
…OTP-17437' into maint

* john/compiler/validator-container-type-subtraction-pt3/OTP-17437:
  beam_validator: Fix silly mistake in infer_types
  • Loading branch information
jhogberg committed May 28, 2021
2 parents 0b38c21 + 1eed7ba commit e39afff
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/compiler/src/beam_validator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1998,13 +1998,15 @@ infer_types_1(#value{op={bif,tuple_size}, args=[Tuple]},
ne_exact -> update_type(fun subtract/2, Type, Tuple, Vst)
end;
infer_types_1(#value{op={bif,element},args=[{integer,Index}, Tuple]},
Val, eq_exact, Vst) ->
Val, eq_exact, Vst)
when Index >= 1 ->
ValType = get_term_type(Val, Vst),
Es = beam_types:set_tuple_element(Index, ValType, #{}),
TupleType = #t_tuple{size=Index,elements=Es},
update_type(fun meet/2, TupleType, Tuple, Vst);
infer_types_1(#value{op={bif,element},args=[{integer,Index}, Tuple]},
Val, ne_exact, Vst) ->
Val, ne_exact, Vst)
when Index >= 1 ->
%% Subtraction is only safe with singletons, see update_ne_types/3 for
%% details.
ValType = get_term_type(Val, Vst),
Expand Down

0 comments on commit e39afff

Please sign in to comment.