aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-09-09 11:52:21 +0200
committerBjörn Gustavsson <[email protected]>2013-09-09 11:52:21 +0200
commit45eaf81506de99c915fe480553bf761667627001 (patch)
tree238f5202860e61ccc73555bd8a68940c6ac92819
parentf461ee79e2dde881bc5ba9c7fe729993ccfe2884 (diff)
parent2f2824519d13e7745c02efbc7c29c37a76885fee (diff)
downloadotp-45eaf81506de99c915fe480553bf761667627001.tar.gz
otp-45eaf81506de99c915fe480553bf761667627001.tar.bz2
otp-45eaf81506de99c915fe480553bf761667627001.zip
Merge branch 'maint'
* maint: compiler: Conform returned errors to the documented format
-rw-r--r--lib/compiler/doc/src/compile.xml4
-rw-r--r--lib/compiler/src/compile.erl31
-rw-r--r--lib/compiler/src/core_lint.erl2
-rw-r--r--lib/compiler/src/v3_kernel.erl2
-rw-r--r--lib/compiler/test/compile_SUITE.erl4
-rw-r--r--lib/compiler/test/core_fold_SUITE.erl2
6 files changed, 30 insertions, 15 deletions
diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml
index 96907f6b10..73d75851cf 100644
--- a/lib/compiler/doc/src/compile.xml
+++ b/lib/compiler/doc/src/compile.xml
@@ -859,6 +859,10 @@ pi() -> 3.1416.
{ErrorLine, Module, ErrorDescriptor}
</code>
+ <p><c>ErrorLine</c> will be the atom <c>none</c> if the error does
+ not correspond to a specific line (e.g. if the source file does
+ not exist).</p>
+
<p>A string describing the error is obtained with the following
call:</p>
<code>
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 2ca403de54..802e3dfa2f 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -41,7 +41,8 @@
-type option() :: atom() | {atom(), term()} | {'d', atom(), term()}.
--type err_info() :: {erl_scan:line(), module(), term()}. %% ErrorDescriptor
+-type err_info() :: {erl_scan:line() | 'none',
+ module(), term()}. %% ErrorDescriptor
-type errors() :: [{file:filename(), [err_info()]}].
-type warnings() :: [{file:filename(), [err_info()]}].
-type mod_ret() :: {'ok', module()}
@@ -1290,10 +1291,10 @@ native_compile_1(St) ->
{error,R} ->
case IgnoreErrors of
true ->
- Ws = [{St#compile.ifile,[{?MODULE,{native,R}}]}],
+ Ws = [{St#compile.ifile,[{none,?MODULE,{native,R}}]}],
{ok,St#compile{warnings=St#compile.warnings ++ Ws}};
false ->
- Es = [{St#compile.ifile,[{?MODULE,{native,R}}]}],
+ Es = [{St#compile.ifile,[{none,?MODULE,{native,R}}]}],
{error,St#compile{errors=St#compile.errors ++ Es}}
end
catch
@@ -1302,7 +1303,7 @@ native_compile_1(St) ->
case IgnoreErrors of
true ->
Ws = [{St#compile.ifile,
- [{?MODULE,{native_crash,R,Stk}}]}],
+ [{none,?MODULE,{native_crash,R,Stk}}]}],
{ok,St#compile{warnings=St#compile.warnings ++ Ws}};
false ->
erlang:raise(Class, R, Stk)
@@ -1349,7 +1350,7 @@ save_binary(#compile{module=Mod,ofile=Outfile,
save_binary_1(St);
_ ->
Es = [{St#compile.ofile,
- [{?MODULE,{module_name,Mod,Base}}]}],
+ [{none,?MODULE,{module_name,Mod,Base}}]}],
{error,St#compile{errors=St#compile.errors ++ Es}}
end
end.
@@ -1363,20 +1364,20 @@ save_binary_1(St) ->
ok ->
{ok,St};
{error,RenameError} ->
- Es0 = [{Ofile,[{?MODULE,{rename,Tfile,Ofile,
- RenameError}}]}],
+ Es0 = [{Ofile,[{none,?MODULE,{rename,Tfile,Ofile,
+ RenameError}}]}],
Es = case file:delete(Tfile) of
ok -> Es0;
{error,DeleteError} ->
Es0 ++
[{Ofile,
- [{?MODULE,{delete_temp,Tfile,
- DeleteError}}]}]
+ [{none,?MODULE,{delete_temp,Tfile,
+ DeleteError}}]}]
end,
{error,St#compile{errors=St#compile.errors ++ Es}}
end;
{error,_Error} ->
- Es = [{Tfile,[{compile,write_error}]}],
+ Es = [{Tfile,[{none,compile,write_error}]}],
{error,St#compile{errors=St#compile.errors ++ Es}}
end.
@@ -1419,6 +1420,9 @@ report_warnings(#compile{options=Opts,warnings=Ws0}) ->
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)])},
@@ -1428,12 +1432,17 @@ format_message(F, P, [{Line,Mod,E}|Es]) ->
[F,Line,P,Mod:format_error(E)])},
[M|format_message(F, P, Es)];
format_message(F, P, [{Mod,E}|Es]) ->
+ %% Not documented and not expected to be used any more, but
+ %% keep a while just in case.
M = {none,io_lib:format("~ts: ~s~ts\n", [F,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);
@@ -1441,6 +1450,8 @@ 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, [{Mod,E}|Es]) ->
+ %% Not documented and not expected to be used any more, but
+ %% keep a while just in case.
io:fwrite("~ts: ~ts\n", [F,Mod:format_error(E)]),
list_errors(F, Es);
list_errors(_F, []) -> ok.
diff --git a/lib/compiler/src/core_lint.erl b/lib/compiler/src/core_lint.erl
index 1e8983f594..e5d5fa2bcd 100644
--- a/lib/compiler/src/core_lint.erl
+++ b/lib/compiler/src/core_lint.erl
@@ -162,7 +162,7 @@ return_status(St) ->
%% add_warning(ErrorDescriptor, State) -> State'
%% Note that we don't use line numbers here.
-add_error(E, St) -> St#lint{errors=[{?MODULE,E}|St#lint.errors]}.
+add_error(E, St) -> St#lint{errors=[{none,?MODULE,E}|St#lint.errors]}.
%%add_warning(W, St) -> St#lint{warnings=[{none,core_lint,W}|St#lint.warnings]}.
diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl
index 5f1c108f7c..2b2b8bf550 100644
--- a/lib/compiler/src/v3_kernel.erl
+++ b/lib/compiler/src/v3_kernel.erl
@@ -1875,7 +1875,7 @@ format_error(bad_segment_size) ->
add_warning(none, Term, Anno, #kern{ws=Ws}=St) ->
File = get_file(Anno),
- St#kern{ws=[{File,[{?MODULE,Term}]}|Ws]};
+ St#kern{ws=[{File,[{none,?MODULE,Term}]}|Ws]};
add_warning(Line, Term, Anno, #kern{ws=Ws}=St) ->
File = get_file(Anno),
St#kern{ws=[{File,[{Line,?MODULE,Term}]}|Ws]}.
diff --git a/lib/compiler/test/compile_SUITE.erl b/lib/compiler/test/compile_SUITE.erl
index da8aecdc8b..66ce6c00ab 100644
--- a/lib/compiler/test/compile_SUITE.erl
+++ b/lib/compiler/test/compile_SUITE.erl
@@ -139,8 +139,8 @@ forms_2(Config) when is_list(Config) ->
module_mismatch(Config) when is_list(Config) ->
?line DataDir = ?config(data_dir, Config),
?line File = filename:join(DataDir, "wrong_module_name.erl"),
- ?line {error,[{"wrong_module_name.beam",
- [{compile,{module_name,arne,"wrong_module_name"}}]}],
+ {error,[{"wrong_module_name.beam",
+ [{none,compile,{module_name,arne,"wrong_module_name"}}]}],
[]} = compile:file(File, [return]),
?line error = compile:file(File, [report]),
diff --git a/lib/compiler/test/core_fold_SUITE.erl b/lib/compiler/test/core_fold_SUITE.erl
index abc9ab6a72..a5a4e62a42 100644
--- a/lib/compiler/test/core_fold_SUITE.erl
+++ b/lib/compiler/test/core_fold_SUITE.erl
@@ -299,7 +299,7 @@ unused_multiple_values_error(Config) when is_list(Config) ->
Opts = [no_copt,clint,return,from_core,{outdir,PrivDir}
|test_lib:opt_opts(?MODULE)],
{error,[{unused_multiple_values_error,
- [{core_lint,{return_mismatch,{hello,1}}}]}],
+ [{none,core_lint,{return_mismatch,{hello,1}}}]}],
[]} = c:c(Core, Opts),
ok.