Commit Graph

2 Commits

Author SHA1 Message Date
Zoltan Somogyi
6bfef65f50 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.
2019-10-26 13:21:30 +11:00
Zoltan Somogyi
30901debf3 Warn about infinite recursive calls inside try goals.
compiler/hlds_goal.m:
    Add a goal feature that is intended to mark lambda goals
    created to implement try goals.

compiler/try_expand.m:
    Add this feature to the lambda goals created to implement try goals.

compiler/simplify_info.m:
    Replace an old counter "number of lambdas we are inside" with a
    slightly different counter "number of non-try lambdas we are inside".
    Move the position of the counter in its structure to reveal
    all the places that must be updated to account for this.

compiler/simplify_goal_unify.m:
    Do NOT increment the changed counter while traversing lambda goals
    that are part of the implementation of try goals.

compiler/simplify_goal_call.m:
    We used to suppress the generation of warnings about infinite recursion
    if we were inside any lambdas. This is because if the code of e.g.
    "p(InArgs, OutArgsA)" constructs a higher order value that contains
    the apparently-infinitely-recursive call "p(InARgs, OutArgsB)",
    the code that calls the new closure may well be *outside* the call tree
    of predicate p, and would thus no longer be recursive.

    However, a closure constructed to implement a try goal *will* be called
    inside the predicate that constructs it. So we now suppress the warning
    only if the number of *non-try* lambdas we are inside is nonzero.
    This is the motive behind the change in semantics in simplify_info.

    This implements feature request Mantis #477.

compiler/simplify_proc.m:
compiler/saved_vars.m:
    Conform to the changes above.

tests/warnings/bug477.{m,exp}:
    A test case for the new functionality.

tests/warnings/Mmakefile:
    Enable the new test.
2019-04-20 12:00:40 +10:00