Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
0112-typer-Correct-broken-handling-of-contract-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0112-typer-Correct-broken-handling-of-contract-violations.patch of Package erlang
From 57cbb37d52d37afa2a37734c53cb851f2aeeb868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Wed, 21 Sep 2022 14:31:32 +0200 Subject: [PATCH] typer: Correct broken handling of contract violations --- lib/dialyzer/src/typer_core.erl | 2 +- lib/dialyzer/test/typer_SUITE.erl | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/dialyzer/src/typer_core.erl b/lib/dialyzer/src/typer_core.erl index 408cd0f1d6..1556d0b09b 100644 --- a/lib/dialyzer/src/typer_core.erl +++ b/lib/dialyzer/src/typer_core.erl @@ -438,7 +438,7 @@ get_type({{M, F, A} = MFA, Range, Arg}, CodeServer, Records, Analysis) -> {{F, A}, {contract, Contract}}; {error, {overlapping_contract, []}} -> {{F, A}, {contract, Contract}}; - {error, invalid_contract} -> + {error, {invalid_contract, _}} -> CString = dialyzer_contracts:contract_to_string(Contract), SigString = dialyzer_utils:format_sig(Sig, Records), Msg = io_lib:format("Error in contract of function ~w:~tw/~w\n" diff --git a/lib/dialyzer/test/typer_SUITE.erl b/lib/dialyzer/test/typer_SUITE.erl index 2ad205d880..661357d383 100644 --- a/lib/dialyzer/test/typer_SUITE.erl +++ b/lib/dialyzer/test/typer_SUITE.erl @@ -21,14 +21,16 @@ -export([all/0,suite/0,groups/0,init_per_suite/1,end_per_suite/1, init_per_group/2,end_per_group/2, - smoke/1]). + smoke/1, + contract_violation/1]). -include_lib("common_test/include/ct.hrl"). suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [smoke]. + [smoke, + contract_violation]. groups() -> []. @@ -66,6 +68,29 @@ smoke(Config) -> run(Config, Args, Src, Res), ok. +contract_violation(Config) -> + OutDir = proplists:get_value(priv_dir, Config), + case dialyzer_common:check_plt(OutDir) of + fail -> + {skip, "Plt creation/check failed."}; + ok -> + Code = <<"-module(typer_test_module). + -export([foo/1]). + -spec foo(boolean()) -> string(). + foo(N) -> + integer_to_list(N).">>, + PrivDir = proplists:get_value(priv_dir, Config), + Src = filename:join(PrivDir, "typer_test_module.erl"), + ok = file:write_file(Src, Code), + Args = "--plt " ++ PrivDir ++ "dialyzer_plt", + Res = ["^typer: Error in contract of function typer_test_module:foo/1", + "^\t The contract is: \\(boolean\\(\\)\\) -> string\\(\\)", + "^\t but the inferred signature is: \\(integer\\(\\)\\) -> string\\(\\)", + "_ERROR_"], + run(Config, Args, Src, Res), + ok + end. + typer() -> case os:find_executable("typer") of false -> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor