diff options
author | John Högberg <[email protected]> | 2019-04-25 11:55:02 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-04-25 11:55:02 +0200 |
commit | 7ac0c1618790afead87072b86f3316e53916699a (patch) | |
tree | e1df4e32144080fdb90823310282c9fb6578b1c6 /lib/compiler/test | |
parent | 71f6a4e4a3fb39fb2d90a31a00093c018ece328a (diff) | |
parent | 64a6cdc80e2f3c33c3cb18b41721b2738337cb56 (diff) | |
download | otp-7ac0c1618790afead87072b86f3316e53916699a.tar.gz otp-7ac0c1618790afead87072b86f3316e53916699a.tar.bz2 otp-7ac0c1618790afead87072b86f3316e53916699a.zip |
Merge branch 'john/compiler/fix-validator-inference-on-dead-values/ERIERL-348'
* john/compiler/fix-validator-inference-on-dead-values/ERIERL-348:
beam_validator: Don't infer types for dead values
Diffstat (limited to 'lib/compiler/test')
-rw-r--r-- | lib/compiler/test/beam_validator_SUITE.erl | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/compiler/test/beam_validator_SUITE.erl b/lib/compiler/test/beam_validator_SUITE.erl index de5a3c2873..6b1438abdd 100644 --- a/lib/compiler/test/beam_validator_SUITE.erl +++ b/lib/compiler/test/beam_validator_SUITE.erl @@ -35,7 +35,7 @@ map_field_lists/1,cover_bin_opt/1, val_dsetel/1,bad_tuples/1,bad_try_catch_nesting/1, receive_stacked/1,aliased_types/1,type_conflict/1, - infer_on_eq/1]). + infer_on_eq/1,infer_dead_value/1]). -include_lib("common_test/include/ct.hrl"). @@ -65,7 +65,7 @@ groups() -> map_field_lists,cover_bin_opt,val_dsetel, bad_tuples,bad_try_catch_nesting, receive_stacked,aliased_types,type_conflict, - infer_on_eq]}]. + infer_on_eq,infer_dead_value]}]. init_per_suite(Config) -> test_lib:recompile(?MODULE), @@ -679,6 +679,27 @@ infer_on_eq_4(T) -> true = erlang:tuple_size(T) =:= 1, {ok, erlang:element(1, T)}. +%% ERIERL-348; types were inferred for dead values, causing validation to fail. + +infer_dead_value(Config) when is_list(Config) -> + a = idv_1({a, b, c, d, e, f, g}, {0, 0, 0, 0, 0, 0, 0}), + b = idv_1({a, b, c, d, 0, 0, 0}, {a, b, c, d, 0, 0, 0}), + c = idv_1({0, 0, 0, 0, 0, f, g}, {0, 0, 0, 0, 0, f, g}), + error = idv_1(gurka, gaffel), + ok. + +idv_1({_A, _B, _C, _D, _E, _F, _G}, + {0, 0, 0, 0, 0, 0, 0}) -> + a; +idv_1({A, B, C, D,_E, _F, _G}=_Tuple1, + {A, B, C, D, 0, 0, 0}=_Tuple2) -> + b; +idv_1({_A, _B, _C, _D, _E, F, G}, + {0, 0, 0, 0, 0, F, G}) -> + c; +idv_1(_A, _B) -> + error. + %%%------------------------------------------------------------------------- transform_remove(Remove, Module) -> |