aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStavros Aronis <[email protected]>2011-05-23 17:10:01 +0300
committerStavros Aronis <[email protected]>2011-05-23 17:21:06 +0300
commitb4d94db355d69f80aeb39ca9efe80fb9e2f56c57 (patch)
tree9c6584867fea6e5257a3fe206f6427425fff2ad6 /lib
parent50d3615bf79bcb658f0af595b646e3210c634365 (diff)
downloadotp-b4d94db355d69f80aeb39ca9efe80fb9e2f56c57.tar.gz
otp-b4d94db355d69f80aeb39ca9efe80fb9e2f56c57.tar.bz2
otp-b4d94db355d69f80aeb39ca9efe80fb9e2f56c57.zip
Fix crash when a contract range warning is emitted for a module already in plt
Warnings about wrong contract ranges are post-processed to be displayed in the file/line that contains the contract, although they can also be emitted while processing other modules. For this relocation to succeed the module that contains the contract should be currently under analysis. If this is not the case the warning is displayed in the file/line of the call that proves the discrepancy in the contract.
Diffstat (limited to 'lib')
-rw-r--r--lib/dialyzer/src/dialyzer_succ_typings.erl33
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/dialyzer/src/dialyzer_succ_typings.erl b/lib/dialyzer/src/dialyzer_succ_typings.erl
index b8da57d3f9..dc5a3fed37 100644
--- a/lib/dialyzer/src/dialyzer_succ_typings.erl
+++ b/lib/dialyzer/src/dialyzer_succ_typings.erl
@@ -158,20 +158,27 @@ postprocess_dataflow_warns([], _State, WAcc, Acc) ->
postprocess_dataflow_warns([{?WARN_CONTRACT_RANGE, {CallF, CallL}, Msg}|Rest],
#st{codeserver = Codeserver} = State, WAcc, Acc) ->
{contract_range, [Contract, M, F, A, ArgStrings, CRet]} = Msg,
- {ok, {{ContrF, _ContrL} = FileLine, _C}} =
- dialyzer_codeserver:lookup_mfa_contract({M,F,A}, Codeserver),
- case CallF =:= ContrF of
- true ->
+ case dialyzer_codeserver:lookup_mfa_contract({M,F,A}, Codeserver) of
+ {ok, {{ContrF, _ContrL} = FileLine, _C}} ->
+ case CallF =:= ContrF of
+ true ->
+ NewMsg = {contract_range, [Contract, M, F, ArgStrings, CallL, CRet]},
+ W = {?WARN_CONTRACT_RANGE, FileLine, NewMsg},
+ Filter =
+ fun({?WARN_CONTRACT_TYPES, FL, _}) when FL =:= FileLine -> false;
+ (_) -> true
+ end,
+ FilterWAcc = lists:filter(Filter, WAcc),
+ postprocess_dataflow_warns(Rest, State, FilterWAcc, [W|Acc]);
+ false ->
+ postprocess_dataflow_warns(Rest, State, WAcc, Acc)
+ end;
+ error ->
+ %% The contract is not in a module that is currently under analysis.
+ %% We display the warning in the file/line of the call.
NewMsg = {contract_range, [Contract, M, F, ArgStrings, CallL, CRet]},
- W = {?WARN_CONTRACT_RANGE, FileLine, NewMsg},
- Filter =
- fun({?WARN_CONTRACT_TYPES, FL, _}) when FL =:= FileLine -> false;
- (_) -> true
- end,
- FilterWAcc = lists:filter(Filter, WAcc),
- postprocess_dataflow_warns(Rest, State, FilterWAcc, [W|Acc]);
- false ->
- postprocess_dataflow_warns(Rest, State, WAcc, Acc)
+ W = {?WARN_CONTRACT_RANGE, {CallF, CallL}, NewMsg},
+ postprocess_dataflow_warns(Rest, State, WAcc, [W|Acc])
end;
postprocess_dataflow_warns([W|Rest], State, Wacc, Acc) ->
postprocess_dataflow_warns(Rest, State, Wacc, [W|Acc]).