diff options
author | Hans Bolinder <[email protected]> | 2016-06-09 09:18:35 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2016-06-09 09:18:35 +0200 |
commit | 7f2a5750d896febf39a51c488f57c4235e34a040 (patch) | |
tree | 14adc52f4466bd8a58caaadb289f295d9ea6edfb | |
parent | 8de8b36d4a19a79dd1bd1b49a4c394348edd9eac (diff) | |
parent | 6a0d7e9abef8474ae1de739868ecb2245e8aa6a8 (diff) | |
download | otp-7f2a5750d896febf39a51c488f57c4235e34a040.tar.gz otp-7f2a5750d896febf39a51c488f57c4235e34a040.tar.bz2 otp-7f2a5750d896febf39a51c488f57c4235e34a040.zip |
Merge branch 'hasse/dialyzer/fix_constraint_loop/ERL-157/OTP-13653'
* hasse/dialyzer/fix_constraint_loop/ERL-157/OTP-13653:
Dialyzer: Fix a bug that caused Dialyzer to go into an infinite loop.
-rw-r--r-- | lib/dialyzer/src/dialyzer_contracts.erl | 11 | ||||
-rw-r--r-- | lib/dialyzer/test/small_SUITE_data/src/loopy.erl | 17 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl index d1ffa07706..272ad10e90 100644 --- a/lib/dialyzer/src/dialyzer_contracts.erl +++ b/lib/dialyzer/src/dialyzer_contracts.erl @@ -591,10 +591,13 @@ remove_uses([{Var, Use}|ToRemove], Constrs0) -> remove_uses(_Var, _Use, []) -> []; remove_uses(Var, Use, [Constr|Constrs]) -> {V, Form} = Constr, - case erl_types:t_var_name(V) =:= Var of - true -> [{V, remove_use(Form, Use)}|Constrs]; - false -> [Constr|remove_uses(Var, Use, Constrs)] - end. + NewConstr = case erl_types:t_var_name(V) =:= Var of + true -> + {V, remove_use(Form, Use)}; + false -> + Constr + end, + [NewConstr|remove_uses(Var, Use, Constrs)]. remove_use({var, L, V}, V) -> {var, L, '_'}; remove_use(T, V) when is_tuple(T) -> diff --git a/lib/dialyzer/test/small_SUITE_data/src/loopy.erl b/lib/dialyzer/test/small_SUITE_data/src/loopy.erl new file mode 100644 index 0000000000..28125ec3d9 --- /dev/null +++ b/lib/dialyzer/test/small_SUITE_data/src/loopy.erl @@ -0,0 +1,17 @@ +%% ERL-157, OTP-13653. +%% Would cause Dialyzer to go into an infinite loop. + +-module(loopy). + +-export([loop/1]). + + +-spec loop(Args) -> ok when + Args :: [{Module, Args}], + Module :: module(), + Args :: any(). +loop([{Module, Args} | Rest]) -> + Module:init(Args), + loop(Rest); +loop([]) -> + ok. |