Fix the reminder about hidden messages itself being hidden.

compiler/mercury_compile_main.m:
    When we generate more messages for the user than we show, either
    because of --limited-error-context options or because the user has
    not asked for the verbose part of messages, we used to print a reminder
    about this fact in only one case:

    - at the end of the compilation, and
    - only if the exit status wasn't zero.

    Both of these condition was wrong.

    - If we were compiling modules a, b, c, d ... z, we could get a message
      about more messages being available being printed after the compilation
      of a module (z) for which we generated *no* messages at all, just because
      some message earlier in the list got such messages.

    - If the compilation generated no errors but only warnings, then
      we never printed reminders about any verbose parts of those warnings
      being held back.

    Fix both of these issues by

    - separating the code doing the reminder into its own predicate,
      and invoking it at the end of the processing of each module
      (leaving a call at its old location where it is invoked
      after we have processed all modules), and

    - not making the invocation conditional on exit status.

tests/warnings/ambiguous_overloading.exp:
tests/warnings/arg_order_rearrangment.exp:
tests/warnings/bug477.exp:
tests/warnings/infinite_recursion.exp:
tests/warnings/simple_code.exp:
tests/warnings/singleton_test.exp:
tests/warnings/singleton_test.exp2:
tests/warnings/singleton_test.exp3:
tests/warnings/singleton_test.exp4:
    Update these to expect the "For more information, recompile with `-E'"
    message, now that we don't hide it.

tests/warnings/singleton_test.m:
    Document what the four .exp files are for.
This commit is contained in:
Zoltan Somogyi
2019-10-26 13:21:30 +11:00
parent 23d1c677ff
commit 6bfef65f50
11 changed files with 55 additions and 36 deletions

View File

@@ -781,40 +781,9 @@ do_op_mode_args(Globals, OpModeArgs, FileNamesFromStdin, DetectedGradeFlags,
true
)
else
% If we suppressed the printing of some errors, then tell the user
% about this fact, because the absence of any errors being printed
% during a failing compilation would otherwise be likely to be
% baffling.
globals.io_get_some_errors_were_context_limited(Limited, !IO),
(
Limited = no
;
Limited = yes,
io.write_string("Some error messages were suppressed " ++
"by `--limit-error-contexts' options.\n", !IO),
io.write_string("You can see the suppressed messages " ++
"if you recompile without these options.\n", !IO)
),
% If we found some errors, but the user didn't enable the `-E'
% (`--verbose-errors') option, give them a hint about it.
% Of course, we should only output the hint when we have further
% information to give the user.
globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
globals.io_get_extra_error_info(ExtraErrorInfo, !IO),
(
VerboseErrors = no,
(
ExtraErrorInfo = yes,
io.write_string("For more information, " ++
"recompile with `-E'.\n", !IO)
;
ExtraErrorInfo = no
)
;
VerboseErrors = yes
)
true
),
maybe_print_delayed_error_messages(Globals, !IO),
globals.lookup_bool_option(Globals, statistics, Statistics),
(
Statistics = yes,
@@ -823,6 +792,45 @@ do_op_mode_args(Globals, OpModeArgs, FileNamesFromStdin, DetectedGradeFlags,
Statistics = no
).
:- pred maybe_print_delayed_error_messages(globals::in, io::di, io::uo) is det.
maybe_print_delayed_error_messages(Globals, !IO) :-
% Pick up the values of these flags, and then reset them
% for the next module.
globals.io_get_some_errors_were_context_limited(Limited, !IO),
globals.io_set_some_errors_were_context_limited(no, !IO),
globals.io_get_extra_error_info(ExtraErrorInfo, !IO),
globals.io_set_extra_error_info(no, !IO),
% If we suppressed the printing of some errors, then tell the user
% about this fact, because the absence of any errors being printed
% during a failing compilation would otherwise be likely to be baffling.
(
Limited = no
;
Limited = yes,
io.write_string("Some error messages were suppressed " ++
"by `--limit-error-contexts' options.\n", !IO),
io.write_string("You can see the suppressed messages " ++
"if you recompile without these options.\n", !IO)
),
% If we found some errors, but the user didn't enable the `-E'
% (`--verbose-errors') option, give them a hint about it.
(
ExtraErrorInfo = no
;
ExtraErrorInfo = yes,
globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
(
VerboseErrors = no,
io.write_string("For more information, recompile with `-E'.\n",
!IO)
;
VerboseErrors = yes
)
).
:- type compile == pred(globals, bool, io, io).
:- inst compile == (pred(in, out, di, uo) is det).
@@ -1082,6 +1090,7 @@ do_process_compiler_arg(Globals0, OpModeArgs, OptionArgs, FileOrModule,
split_into_compilation_units_perform_checks(ParseTreeSrc,
RawCompUnits, Specs0, Specs),
write_error_specs_ignore(Specs, Globals, !IO),
maybe_print_delayed_error_messages(Globals, !IO),
(
InterfaceFile = omif_int0,
list.foldl(
@@ -1994,7 +2003,8 @@ maybe_grab_optfiles(Globals, OpModeAugment, Verbose, MaybeTransOptDeps,
then
maybe_write_string(Verbose, "% Reading .opt files...\n", !IO),
maybe_flush_output(Verbose, !IO),
grab_opt_files(Globals, ModuleAndImports0, ModuleAndImports1, Error1, !IO),
grab_opt_files(Globals, ModuleAndImports0, ModuleAndImports1, Error1,
!IO),
maybe_write_string(Verbose, "% Done.\n", !IO)
else
ModuleAndImports1 = ModuleAndImports0,

View File

@@ -62,3 +62,4 @@ ambiguous_overloading.m:083: The function symbol `lookup_bool_option'/2 is
ambiguous_overloading.m:083: also overloaded here.
ambiguous_overloading.m:084: The function symbol `lookup_bool_option'/2 is
ambiguous_overloading.m:084: also overloaded here.
For more information, recompile with `-E'.

View File

@@ -7,3 +7,4 @@ arg_order_rearrangment.m:014: Please ensure that this argument rearrangement
arg_order_rearrangment.m:014: does not introduce performance problems.
arg_order_rearrangment.m:014: These warnings can be suppressed by
arg_order_rearrangment.m:014: `--no-warn-accumulator-swaps'.
For more information, recompile with `-E'.

View File

@@ -1,2 +1,3 @@
bug477.m:036: Warning: recursive call to predicate `reconstruct_route'/3 will
bug477.m:036: lead to infinite recursion.
For more information, recompile with `-E'.

View File

@@ -4,3 +4,4 @@ infinite_recursion.m:034: Warning: recursive call to predicate `loop'/0 will
infinite_recursion.m:034: lead to infinite recursion.
infinite_recursion.m:046: Warning: recursive call to predicate `funny_append'/3
infinite_recursion.m:046: will lead to infinite recursion.
For more information, recompile with `-E'.

View File

@@ -26,3 +26,4 @@ simple_code.m:080: warning: unification of `HeadVar__1' and 2 cannot succeed.
simple_code.m:080: `HeadVar__1' has instantiatedness `bound(1)'.
simple_code.m:113: Warning: recursive call to predicate `anc'/2 will lead to
simple_code.m:113: infinite recursion.
For more information, recompile with `-E'.

View File

@@ -25,3 +25,4 @@ singleton_test.m:095: scope.
singleton_test.m:095: In clause for predicate `singleton_test.test_head'/6:
singleton_test.m:095: warning: variables `A, B' occur only once in this
singleton_test.m:095: scope.
For more information, recompile with `-E'.

View File

@@ -26,3 +26,4 @@ singleton_test.m:095: scope.
singleton_test.m:095: In clause for predicate `singleton_test.test_head'/6:
singleton_test.m:095: warning: variables `A, B' occur only once in this
singleton_test.m:095: scope.
For more information, recompile with `-E'.

View File

@@ -28,3 +28,4 @@ singleton_test.m:095: scope.
singleton_test.m:095: In clause for predicate `singleton_test.test_head'/6:
singleton_test.m:095: warning: variables `A, B' occur only once in this
singleton_test.m:095: scope.
For more information, recompile with `-E'.

View File

@@ -30,3 +30,4 @@ singleton_test.m:095: scope.
singleton_test.m:095: In clause for predicate `singleton_test.test_head'/6:
singleton_test.m:095: warning: variables `A, B' occur only once in this
singleton_test.m:095: scope.
For more information, recompile with `-E'.

View File

@@ -1,11 +1,11 @@
%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
% The .exp files are for C, C#, Java and Erlang respectively.
:- module singleton_test.
:- interface.
:- import_module io.
:- import_module list.
:- import_module io, list.
:- pred my_append(list(int), list(int), list(int)).
:- mode my_append(in, in, out) is det.