diff options
author | John Högberg <john@erlang.org> | 2023-03-03 13:18:29 +0100 |
---|---|---|
committer | John Högberg <john@erlang.org> | 2023-03-03 13:27:39 +0100 |
commit | e18a83f3d80882b2facc470f2437d6b31511e829 (patch) | |
tree | eb539b364e5e5371e4cf56ef02353c07c3207bf7 | |
parent | 7a482881f7491b779d27bbcb77bc0ceb08640b26 (diff) | |
download | erlang-e18a83f3d80882b2facc470f2437d6b31511e829.tar.gz |
beam_validator: Skip unnecessary type updates
-rw-r--r-- | lib/compiler/src/beam_validator.erl | 2 | ||||
-rw-r--r-- | lib/compiler/test/beam_validator_SUITE.erl | 19 |
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index 98eacce0fc..b38d288f99 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -2299,6 +2299,8 @@ update_type(Merge, With, #value_ref{}=Ref, Vst0) -> case Merge(Current, With) of none -> throw({type_conflict, Current, With}); + Current -> + Vst0; Type -> Vst = update_container_type(Type, Ref, Vst0), set_type(Type, Ref, Vst) diff --git a/lib/compiler/test/beam_validator_SUITE.erl b/lib/compiler/test/beam_validator_SUITE.erl index 64a356c7e4..aba3b8dfe2 100644 --- a/lib/compiler/test/beam_validator_SUITE.erl +++ b/lib/compiler/test/beam_validator_SUITE.erl @@ -41,7 +41,8 @@ missing_return_type/1,will_succeed/1, bs_saved_position_units/1,parent_container/1, container_performance/1, - not_equal_inference/1]). + not_equal_inference/1, + inert_update_type/1]). -include_lib("common_test/include/ct.hrl"). @@ -77,7 +78,8 @@ groups() -> missing_return_type,will_succeed, bs_saved_position_units,parent_container, container_performance, - not_equal_inference]}]. + not_equal_inference, + inert_update_type]}]. init_per_suite(Config) -> test_lib:recompile(?MODULE), @@ -1045,5 +1047,18 @@ not_equal_inference(_Config) -> 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. |