diff options
author | Björn Gustavsson <bjorn@erlang.org> | 2021-02-10 05:59:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-10 05:59:47 +0100 |
commit | d3c315ba33be7d35c4df0604430c6075595c1833 (patch) | |
tree | ab57ccfad1a7f9e30f2b6e7f1100dd39d70aa0d0 /lib/compiler/src/compile.erl | |
parent | a92d6cde98564d5ff0db3bfbd44a0597c85b57d7 (diff) | |
parent | 32532595576c45ade31105b807b70e12be9d937e (diff) | |
download | erlang-d3c315ba33be7d35c4df0604430c6075595c1833.tar.gz |
Merge pull request #3020 from WhatsApp/quote-source
Quote source as part of error messages
Diffstat (limited to 'lib/compiler/src/compile.erl')
-rw-r--r-- | lib/compiler/src/compile.erl | 34 |
1 files changed, 4 insertions, 30 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index b8921573d4..cd6a9fa2cd 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -1748,8 +1748,8 @@ write_binary(Name, Bin, St) -> report_errors(#compile{options=Opts,errors=Errors}) -> case member(report_errors, Opts) of true -> - foreach(fun ({{F,_L},Eds}) -> list_errors(F, Eds); - ({F,Eds}) -> list_errors(F, Eds) end, + foreach(fun ({{F,_L},Eds}) -> sys_messages:list_errors(F, Eds, Opts); + ({F,Eds}) -> sys_messages:list_errors(F, Eds, Opts) end, Errors); false -> ok end. @@ -1763,40 +1763,14 @@ report_warnings(#compile{options=Opts,warnings=Ws0}) -> ReportWerror = Werror andalso member(report_errors, Opts), case member(report_warnings, Opts) orelse ReportWerror of true -> - Ws1 = flatmap(fun({{F,_L},Eds}) -> format_message(F, P, Eds); - ({F,Eds}) -> format_message(F, P, Eds) end, + Ws1 = flatmap(fun({{F,_L},Eds}) -> sys_messages:format_messages(F, P, Eds, Opts); + ({F,Eds}) -> sys_messages:format_messages(F, P, Eds, Opts) end, Ws0), Ws = lists:sort(Ws1), foreach(fun({_,Str}) -> io:put_chars(Str) end, Ws); false -> ok end. -format_message(F, P, [{none,Mod,E}|Es]) -> - M = {none,io_lib:format("~ts: ~s~ts\n", [F,P,Mod:format_error(E)])}, - [M|format_message(F, P, Es)]; -format_message(F, P, [{{Line,Column}=Loc,Mod,E}|Es]) -> - M = {{F,Loc},io_lib:format("~ts:~w:~w: ~s~ts\n", - [F,Line,Column,P,Mod:format_error(E)])}, - [M|format_message(F, P, Es)]; -format_message(F, P, [{Line,Mod,E}|Es]) -> - M = {{F,{Line,0}},io_lib:format("~ts:~w: ~s~ts\n", - [F,Line,P,Mod:format_error(E)])}, - [M|format_message(F, P, Es)]; -format_message(_, _, []) -> []. - -%% list_errors(File, ErrorDescriptors) -> ok - -list_errors(F, [{none,Mod,E}|Es]) -> - io:fwrite("~ts: ~ts\n", [F,Mod:format_error(E)]), - list_errors(F, Es); -list_errors(F, [{{Line,Column},Mod,E}|Es]) -> - io:fwrite("~ts:~w:~w: ~ts\n", [F,Line,Column,Mod:format_error(E)]), - list_errors(F, Es); -list_errors(F, [{Line,Mod,E}|Es]) -> - io:fwrite("~ts:~w: ~ts\n", [F,Line,Mod:format_error(E)]), - list_errors(F, Es); -list_errors(_F, []) -> ok. - %% erlfile(Dir, Base) -> ErlFile %% outfile(Base, Extension, Options) -> OutputFile %% objfile(Base, Target, Options) -> ObjFile |