summaryrefslogtreecommitdiff
path: root/lib/compiler/test/beam_validator_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compiler/test/beam_validator_SUITE.erl')
-rw-r--r--lib/compiler/test/beam_validator_SUITE.erl83
1 files changed, 71 insertions, 12 deletions
diff --git a/lib/compiler/test/beam_validator_SUITE.erl b/lib/compiler/test/beam_validator_SUITE.erl
index b112bef22e..aba3b8dfe2 100644
--- a/lib/compiler/test/beam_validator_SUITE.erl
+++ b/lib/compiler/test/beam_validator_SUITE.erl
@@ -38,9 +38,11 @@
infer_on_eq/1,infer_dead_value/1,infer_on_ne/1,
branch_to_try_handler/1,call_without_stack/1,
receive_marker/1,safe_instructions/1,
- missing_return_type/1,will_bif_succeed/1,
+ missing_return_type/1,will_succeed/1,
bs_saved_position_units/1,parent_container/1,
- container_performance/1]).
+ container_performance/1,
+ not_equal_inference/1,
+ inert_update_type/1]).
-include_lib("common_test/include/ct.hrl").
@@ -73,9 +75,11 @@ groups() ->
infer_on_eq,infer_dead_value,infer_on_ne,
branch_to_try_handler,call_without_stack,
receive_marker,safe_instructions,
- missing_return_type,will_bif_succeed,
+ missing_return_type,will_succeed,
bs_saved_position_units,parent_container,
- container_performance]}].
+ container_performance,
+ not_equal_inference,
+ inert_update_type]}].
init_per_suite(Config) ->
test_lib:recompile(?MODULE),
@@ -805,7 +809,7 @@ bs_saved_position_units(Config) when is_list(Config) ->
{'%',
{var_info,
{x,0},
- [{type,{t_bs_context,8,0,0}},accepts_match_context]}},
+ [{type,{t_bs_context,8}},accepts_match_context]}},
{move,nil,{x,0}},
return]},
{function,no_errors,1,4,
@@ -866,8 +870,8 @@ bs_saved_position_units(Config) when is_list(Config) ->
{{call_only,1,{f,2}},
14,
{bad_arg_type,{x,0},
- {t_bs_context,12,0,0},
- {t_bs_context,8,0,0}}}}] = Errors,
+ {t_bs_context,12},
+ {t_bs_context,8}}}}] = Errors,
ok.
@@ -930,23 +934,57 @@ night(Turned) ->
participating(_, _, _, _) -> ok.
+will_succeed(_Config) ->
+ ok = will_succeed_1(body),
+
+ self() ! whatever,
+ error = will_succeed_2(),
+
+ self() ! whatever,
+ error = will_succeed_3(),
+
+ ok.
+
%% map_get was known as returning 'none', but 'will_succeed' still returned
%% 'maybe' causing validation to continue, eventually exploding when the 'none'
%% value was used.
-will_bif_succeed(_Config) ->
- ok = f1(body).
-
+%%
%% +no_ssa_opt
-f1(body) when map_get(girl, #{friend => node()}); [], community ->
+will_succeed_1(body) when map_get(girl, #{friend => node()}); [], community ->
case $q and $K of
_V0 ->
0.1825965401179273;
0 ->
state#{[] => 0.10577334580729858, $J => 0}
end;
-f1(body) ->
+will_succeed_1(body) ->
ok.
+%% The apply of 42:name/0 was known to fail, but 'will_succeed' still
+%% returned 'maybe', causing validation to continue and fail because
+%% of the jump to the try_case instruction.
+will_succeed_2() ->
+ try
+ receive
+ _ ->
+ 42
+ end:name()
+ catch
+ _:_ ->
+ error
+ end.
+
+will_succeed_3() ->
+ try
+ receive
+ _ ->
+ 42
+ end:name(a, b)
+ catch
+ _:_ ->
+ error
+ end.
+
%% ERL-1426: When a value was extracted from a tuple, subsequent type tests did
%% not update the type of said tuple.
@@ -1001,5 +1039,26 @@ container_performance(Config) ->
_ -> ok
end.
+%% OTP-18365: A brainfart in inference for '=/=' inverted the results.
+not_equal_inference(_Config) ->
+ {'EXIT', {function_clause, _}} = (catch not_equal_inference_1(id([0]))),
+ ok.
+
+not_equal_inference_1(X) when (X /= []) /= is_port(0 div 0) ->
+ [X || _ <- []].
+
+%% GH-6969: A type was made concrete even though that added no additional
+%% information.
+inert_update_type(_Config) ->
+ hello(<<"string">>, id(42)).
+
+hello(A, B) ->
+ mike([{sys_period, {A, B}}, {some_atom, B}]).
+
+mike([Head | _Rest]) -> joe(Head).
+
+joe({Name, 42}) -> Name;
+joe({sys_period, {A, _B}}) -> {41, 42, A}.
+
id(I) ->
I.