From 573906513fc6e8b6be0833f000907ef3c7e88875 Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Tue, 15 Sep 2020 00:10:34 +0100 Subject: [PATCH] Fix output issue (bug) when `dialyzer.warnings.unknown` is used in `rebar.config` ... and e.g. an unknown type is detected --- src/rebar_dialyzer_format.erl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/rebar_dialyzer_format.erl b/src/rebar_dialyzer_format.erl index cb0e9585..105012aa 100644 --- a/src/rebar_dialyzer_format.erl +++ b/src/rebar_dialyzer_format.erl @@ -27,6 +27,21 @@ format_warnings(Opts, Warnings) -> %% If the last seen file is and the file of this warning are the same + +%% `dialyzer_cl` returns _Filename = "", _Line = 0 for `unknown` +format_warning_(_Opts, Warning = {_Tag, {"" = _SrcFile0, 0 = Line}, Msg}, {_LastFile, Acc}) -> + SrcFile = "", + try + F = fmt("~!_c~ts", [SrcFile]), + String = message_to_string(Msg), + {SrcFile, [lists:flatten(fmt("~n~ts~n~!c~4w~!!: ~ts", [F, Line, String])) | Acc]} + catch + ?WITH_STACKTRACE(Error, Reason, Stacktrace) + ?DEBUG("Failed to pretty format warning: ~p:~p~n~p", + [Error, Reason, Stacktrace]), + {SrcFile, [dialyzer:format_warning(Warning, fullpath) | Acc]} + end; + %% we skip the file header format_warning_(_Opts, Warning = {_Tag, {File, Line}, Msg}, {File, Acc}) -> try