Skip to content

Commit 9aa9f87

Browse files
committed
rebar3_dialyzer_format: Add missing messages
Add missing message string formatting to `rebar3_dialyzer_format`. I ran the following commands for finding missing messages ``` grep '^message_to_string' lib/dialyzer/src/dialyzer.erl | sed 's/message_to_string({\([a-z_]*\),.*/\1/g' | sort > /tmp/otp.txt grep '^message_to_string' src/rebar_dialyzer_format.erl | sed 's/message_to_string({\([a-z_]*\),.*/\1/g' | sort > /tmp/rebar3.txt ``` The missing message types are `callback_not_exported`, `contract_with_opaque` and `map_update`. We already have `invalid_contract` but it has been divided in two functions in OTP project. `race_condition` was deprecated in OTP-25. ``` diff /tmp/rebar3.txt /tmp/otp.txt 7a8 > callback_not_exported 17a19 > contract_with_opaque 27a30,31 > invalid_contract > map_update 43d46 < race_condition ```
1 parent a68b50e commit 9aa9f87

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

apps/rebar/src/rebar_dialyzer_format.erl

+14
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ message_to_string({guard_fail, []}) ->
130130
message_to_string({guard_fail, [Arg1, Infix, Arg2]}) ->
131131
fmt("~!^Guard test ~!!~ts ~ts ~ts~!^ can never succeed",
132132
[Arg1, Infix, Arg2]);
133+
message_to_string({map_update, [Type, Key]}) ->
134+
fmt("~!^A key of type ~!!~ts~!^ cannot exist in a map of type ~!!~ts",
135+
[Key, Type]);
133136
message_to_string({neg_guard_fail, [Arg1, Infix, Arg2]}) ->
134137
fmt("~!^Guard test not(~!!~ts ~ts ~ts~!^) can never succeed",
135138
[Arg1, Infix, Arg2]);
@@ -202,10 +205,18 @@ message_to_string({contract_range, [Contract, M, F, ArgStrings, Line, CRet]}) ->
202205
message_to_string({invalid_contract, [M, F, A, Sig]}) ->
203206
fmt("~!^Invalid type specification for function~!! ~w:~w/~w."
204207
"~!^ The success typing is~!! ~ts", [M, F, A, Sig]);
208+
message_to_string({contract_with_opaque, [M, F, A, OpaqueType, SigType]}) ->
209+
fmt("~!^The specification for ~!!~w:~w/~w~!^ has an opaque"
210+
" subtype ~!!~ts~!^ which is violated by the success typing ~!!~ts",
211+
[M, F, A, OpaqueType, SigType]);
205212
message_to_string({extra_range, [M, F, A, ExtraRanges, SigRange]}) ->
206213
fmt("~!^The specification for ~!!~w:~w/~w~!^ states that the function"
207214
" might also return ~!!~ts~!^ but the inferred return is ~!!~ts",
208215
[M, F, A, ExtraRanges, SigRange]);
216+
message_to_string({missing_range, [M, F, A, ExtraRanges, SigRange]}) ->
217+
fmt("~!^The success typing for ~!!~w:~w/~w~!^ implies that the function"
218+
" might also return ~!!~ts~!^ but the specification return is ~!!~ts",
219+
[M, F, A, ExtraRanges, SigRange]);
209220
message_to_string({overlapping_contract, [M, F, A]}) ->
210221
fmt("~!^Overloaded contract for ~!!~w:~w/~w~!^ has overlapping"
211222
" domains; such contracts are currently unsupported and are simply "
@@ -276,6 +287,9 @@ message_to_string({callback_spec_arg_type_mismatch, [B, F, A, N, ST, CT]}) ->
276287
message_to_string({callback_missing, [B, F, A]}) ->
277288
fmt("~!^Undefined callback function ~!!~w/~w~!^ (behaviour ~!!"
278289
"'~w'~!^)",[F, A, B]);
290+
message_to_string({callback_not_exported, [B, F, A]}) ->
291+
fmt("~!^Callback function ~!!~w/~w~!^ exists but is not exported"
292+
" (behaviour ~!!'~w'~!^)", [F, A, B]);
279293
message_to_string({callback_info_missing, [B]}) ->
280294
fmt("~!^Callback info about the ~!r~w~!!~!^"
281295
" behaviour is not available", [B]);

0 commit comments

Comments
 (0)