diff options
author | Hans Bolinder <[email protected]> | 2017-09-08 13:16:16 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-09-15 08:17:49 +0200 |
commit | 96cf13613c53b641cf7e8a45f83fb71809d6b336 (patch) | |
tree | 264f4c6176e8de70cc8bcb4f4355f8bca47b4254 /lib/dialyzer/src/dialyzer_contracts.erl | |
parent | bd36da0f509ee4e357fdf51b60f3dfcecc824eb8 (diff) | |
download | otp-96cf13613c53b641cf7e8a45f83fb71809d6b336.tar.gz otp-96cf13613c53b641cf7e8a45f83fb71809d6b336.tar.bz2 otp-96cf13613c53b641cf7e8a45f83fb71809d6b336.zip |
dialyzer: Improve check of unknown types
The implementation of OTP-14218 (commit 6d3b38a) has a weakness: only
a very limited part of the type form is checked. This is now fixed:
types not used by specs are checked equally well as types used by
specs.
The new function erl_types:t_from_form_check_remote() checks usage of
remote types. It does not expand used local types, and has (almost) no
limits on depth and size.
Diffstat (limited to 'lib/dialyzer/src/dialyzer_contracts.erl')
-rw-r--r-- | lib/dialyzer/src/dialyzer_contracts.erl | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/dialyzer/src/dialyzer_contracts.erl b/lib/dialyzer/src/dialyzer_contracts.erl index b554ebc2cc..e72c1aecfc 100644 --- a/lib/dialyzer/src/dialyzer_contracts.erl +++ b/lib/dialyzer/src/dialyzer_contracts.erl @@ -555,6 +555,9 @@ from_form_with_check(Form, ExpTypes, MFA, RecordTable, VarTable, Cache) -> Site = {spec, MFA}, C1 = erl_types:t_check_record_fields(Form, ExpTypes, Site, RecordTable, VarTable, Cache), + %% The check costs some time, and with the assumption that contracts + %% are not very deep, it does not add anything. + %% erl_types:t_from_form_check_remote(Form, ExpTypes, MFA, RecordTable), erl_types:t_from_form(Form, ExpTypes, Site, RecordTable, VarTable, C1). constraints_to_dict(Constrs, MFA, RecDict, ExpTypes, RecordTable, @@ -840,7 +843,7 @@ is_remote_types_related(Contract, CSig, Sig, MFA, RecDict) -> t_from_forms_without_remote([{FType, []}], MFA, RecDict) -> Site = {spec, MFA}, - {Type1, _} = erl_types:t_from_form_without_remote(FType, Site, RecDict), + Type1 = erl_types:t_from_form_without_remote(FType, Site, RecDict), {ok, erl_types:subst_all_vars_to_any(Type1)}; t_from_forms_without_remote([{_FType, _Constrs}], _MFA, _RecDict) -> %% 'When' constraints |