diff options
author | John Högberg <john@erlang.org> | 2023-03-15 18:13:02 +0100 |
---|---|---|
committer | John Högberg <john@erlang.org> | 2023-03-15 18:13:02 +0100 |
commit | fdfe130c4249678524adf4c28fd51311eca52c2d (patch) | |
tree | dbe8fcdd68f6f40afdbc467ddcd744c938e61dc9 | |
parent | 81fa9e9374a4908912c1755744c40878295df287 (diff) | |
parent | bb3856bbb72077898d0d8dfb79630c66fef4d7ca (diff) | |
download | erlang-fdfe130c4249678524adf4c28fd51311eca52c2d.tar.gz |
Merge branch 'maint'
* maint:
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 e4a5965dd1..f19ea897fe 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -2549,6 +2549,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 624870659d..6b63f561c1 100644 --- a/lib/compiler/test/beam_validator_SUITE.erl +++ b/lib/compiler/test/beam_validator_SUITE.erl @@ -42,7 +42,8 @@ bs_saved_position_units/1,parent_container/1, container_performance/1, infer_relops/1, - not_equal_inference/1,bad_bin_unit/1,singleton_inference/1]). + not_equal_inference/1,bad_bin_unit/1,singleton_inference/1, + inert_update_type/1]). -include_lib("common_test/include/ct.hrl"). @@ -78,7 +79,8 @@ groups() -> missing_return_type,will_succeed, bs_saved_position_units,parent_container, container_performance,infer_relops, - not_equal_inference,bad_bin_unit,singleton_inference]}]. + not_equal_inference,bad_bin_unit,singleton_inference, + inert_update_type]}]. init_per_suite(Config) -> test_lib:recompile(?MODULE), @@ -1114,5 +1116,18 @@ singleton_inference(Config) -> ok. +%% 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. |