mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-29 00:04:55 +00:00
Estimated hours taken: 4
Branches: main
Improve the compiler's ability to deal with determinism errors, in three ways.
1. Add a new pragma, no_determinism_warning, that suppresses the compiler's
warning about a determinism declaration that is not as tight as possible.
2. When printing determinism errors about disjunctions in supposed-to-be-det
code, print the list of switch arms that the disjunction is in. Without
this, it can be hard to find duplicated cases in a long list of switch
cases. (If the report tells you there is a disjunction in the arm for
f/1 in the switch on X, it tells you that you have duplicated the arm
for X = f(_).)
3. When the compiler prints a message about a switch on a variable not covering
some cases, sometimes the variable is an anonymous variable:
The switch on V_16 does not cover ...
These anonymous variables are created by common-structure elimination,
which groups disjuncts containing unifications such as A = f(a), A = f(b),
A = f(c) into a single arm of the switch on A, A = f(V_16), with a switch
inside that on V_16.
The third part of this diff gives the context of the error in the error
switch as not being the arm for f/1 in the switch on A, but as the arm for
f(V_16) in the switch on A, thus letting users know where the anonymous
variable comes from.
doc/reference_manual.texi:
Document the new pragma.
compiler/prog_item.m:
Add the new pragma to the list of pragmas we recognize.
compiler/hlds_pred.m:
Add the new kind of predicate marker whose presence indicates
that this pragma was given for this predicate.
compiler/prog_io_pragma.m:
Parse the new pragma.
compiler/add_pragma.m:
Process the new pragma: when found, set the marker on the named
predicate.
compiler/det_report.m:
Make all three changes listed above.
In addition, fix a problem that used to happen only rarely:
when printing switch contexts, we used to print them from the inside
out, not the outside in.
Capitalize only the first clause in a multi-clause error message.
compiler/hlds_out_util.m:
Add a function for printing a cons_id either with or without its
arguments, for use by det_report.m Let this function string module
qualifiers from cons_ids, since these are virtually always obvious,
and whose printing is therefore unnecessary clutter.
compiler/equiv_type.m:
compiler/hlds_out_pred.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
compiler/table_gen.m:
Conform to the changes above.
tests/invalid/det_errors.{m,err_exp}:
Add some predicates to this module to test the new functionality,
and update the expected output.
56 lines
3.1 KiB
Plaintext
56 lines
3.1 KiB
Plaintext
det_errors.m:007: In `p1'(in):
|
|
det_errors.m:007: error: determinism declaration not satisfied.
|
|
det_errors.m:007: Declared `det', inferred `semidet'.
|
|
det_errors.m:040: In argument 1 of clause head:
|
|
det_errors.m:040: unification of `HeadVar__1' and `42' can fail.
|
|
det_errors.m:008: In `p2'(in):
|
|
det_errors.m:008: error: determinism declaration not satisfied.
|
|
det_errors.m:008: Declared `det', inferred `semidet'.
|
|
det_errors.m:041: Unification of `X' and `42' can fail.
|
|
det_errors.m:009: In `p3'(in):
|
|
det_errors.m:009: error: determinism declaration not satisfied.
|
|
det_errors.m:009: Declared `det', inferred `semidet'.
|
|
det_errors.m:042: Unification of `X' and `42' can fail.
|
|
det_errors.m:010: In `p4'(in):
|
|
det_errors.m:010: error: determinism declaration not satisfied.
|
|
det_errors.m:010: Declared `det', inferred `semidet'.
|
|
det_errors.m:043: In argument 2 of functor `+/2':
|
|
det_errors.m:043: unification with `21' can fail.
|
|
det_errors.m:024: In `q'(in, out):
|
|
det_errors.m:024: error: determinism declaration not satisfied.
|
|
det_errors.m:024: Declared `det', inferred `semidet'.
|
|
det_errors.m:046: The switch on HeadVar__1 does not cover det_errors.d/0,
|
|
det_errors.m:046: det_errors.e/0, det_errors.f/0, det_errors.g/0,
|
|
det_errors.m:046: det_errors.h/1 or det_errors.i/1.
|
|
det_errors.m:032: In `r'(in, out):
|
|
det_errors.m:032: error: determinism declaration not satisfied.
|
|
det_errors.m:032: Declared `det', inferred `nondet'.
|
|
det_errors.m:052: Inside the case u3(V_16) of the switch on U:
|
|
det_errors.m:052: The switch on V_16 does not cover det_errors.d/0,
|
|
det_errors.m:052: det_errors.e/0, det_errors.f/0, det_errors.g/0,
|
|
det_errors.m:052: det_errors.h/1 or det_errors.i/1.
|
|
det_errors.m:052: Inside the case u4(V_17) of the switch on U:
|
|
det_errors.m:052: inside the case d/0 of the switch on V_17:
|
|
det_errors.m:052: disjunction has multiple clauses with solutions.
|
|
det_errors.m:052: Inside the case u4(V_17) of the switch on U:
|
|
det_errors.m:052: The switch on V_17 does not cover det_errors.h/1 or
|
|
det_errors.m:052: det_errors.i/1.
|
|
det_errors.m:052: The switch on U does not cover det_errors.u2/0.
|
|
det_errors.m:033: In `s'(in, out):
|
|
det_errors.m:033: error: determinism declaration not satisfied.
|
|
det_errors.m:033: Declared `det', inferred `nondet'.
|
|
det_errors.m:091: Inside the case u3(V_11) of the switch on U:
|
|
det_errors.m:091: The switch on V_11 does not cover det_errors.d/0,
|
|
det_errors.m:091: det_errors.e/0, det_errors.f/0, det_errors.g/0,
|
|
det_errors.m:091: det_errors.h/1 or det_errors.i/1.
|
|
det_errors.m:091: The switch on U does not cover det_errors.u2/0.
|
|
det_errors.m:107: Inside the case u4(V) of the switch on U:
|
|
det_errors.m:107: inside the case d/0 of the switch on V:
|
|
det_errors.m:107: disjunction has multiple clauses with solutions.
|
|
det_errors.m:122: Inside the case u4(V) of the switch on U:
|
|
det_errors.m:122: inside the case e/0, f/0 of the switch on V:
|
|
det_errors.m:122: disjunction has multiple clauses with solutions.
|
|
det_errors.m:132: Inside the case u4(V) of the switch on U:
|
|
det_errors.m:132: inside the case h/1, i/1 of the switch on V:
|
|
det_errors.m:132: disjunction has multiple clauses with solutions.
|