mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 04:43:53 +00:00
In case of a problem with an argument of a higher order call,
we used to generate diagnostics containing text such as
in argument 2 (i.e. argument 1 of the called function)
of impure higher-order function call:
This clumsy construction was needed because the HLDS did not contain
enough info. Specifically, it did not specify whether in the source code,
the higher order call was written as e.g. call(P, A, B, C) or as P(A, B, C).
If the former, then then a problem with e.g. A occurs in argument 2
of the call to the 'call' builtin; if the latter, then it occurs
in argument 1 of the call to 'P'.
This diff fixes that. It adds to the HLDS representation of higher order
calls a record of the original form of the call in the source code
compiler/hlds_goal.m:
Add this field, the higher_order_syntax field, to the representation
of higher order calls.
compiler/goal_expr_to_goal.m:
Fill the higher_order_syntax field for higher order predicate calls.
compiler/resolve_unify_functor.m:
Fill the higher_order_syntax field for higher order function calls.
compiler/hlds_pred.m:
Change the representation of generic calls in call_ids, which we use
to identify callees for diagnostics, to include both the variable
specifying the callee in higher order calls (by changing from a
generic_call_id to the generic_call from which it would be derived
by throwing out that info), and the var_name_source needed to
look up its name.
compiler/hlds_out_util.m:
Use the new higher_order_syntax field to generate text that
- identifies the higher order call as using either call(P, A, B, C)
syntax or P(A, B, C) syntax, and likewise for function, and
- specifies the exact argument number (which will depend on the above
distinction).
This should result in more easily understandable diagnostics.
Add a version of this predicate that generates text that specifically
describes the higher order callee, not the higher order call as a whole.
Add an option to suppress the printing of variable names.
We use this to *not* refer to e.g. "the predicate P" when reporting
an error about P actually being a function, not a predicate.
compiler/mode_info.m:
Rename mode_context_call to mode_context_call_arg, because
the context it describes is one argument of a call.
Add a new mode context, mode_context_call, which now describes
a call as a whole.
compiler/mode_errors.m:
Use the new facilies described above to generate better diagnostics
for higher order calls.
compiler/modecheck_util.m:
Document the reason why we handle argument numbers for higher order calls
the way we do.
When generating an error that relates the whole of a higher order call,
use the new mechanism in mode_info.m to record the fact that the error
is not specific to any one argument of the call. Not doing this would
include the argument number in the context of the error, which would be
misleading.
Add a utility function that is needed by more than one module below.
compiler/*.m:
Conform to the changes above.
tests/invalid/anys_in_negated_contexts.err_exp:
tests/invalid/bind_var_errors.err_exp:
tests/invalid/constrained_poly_insts_2.err_exp:
tests/invalid/det_errors_cc.err_exp:
tests/invalid/fbnf.err_exp:
tests/invalid/functor_ho_inst_bad_2.err_exp:
tests/invalid/higher_order_mode_mismatch.err_exp:
tests/invalid/ho_any_inst.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/ho_unique_error.err_exp:
tests/invalid/mode_error_arg_number_ho.err_exp:
tests/invalid/no_ho_inst.err_exp:
tests/invalid/type_diff.err_exp:
tests/invalid_purity/impure_func_t5_fixed.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense_1.err_exp:
tests/invalid_purity/purity_nonsense_2.err_exp:
Expect updated error messages.
59 lines
4.8 KiB
Plaintext
59 lines
4.8 KiB
Plaintext
det_errors_cc.m:021: Error: call to predicate [38;5;87m`det_errors_cc.p1'/2[39;49m with
|
||
det_errors_cc.m:021: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:021: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:022: Call to [38;5;87mp2[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:023: Call to [38;5;87mp3[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:024: Call to [38;5;87mp4[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:025: Call to [38;5;87mp5[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:026: Call to [38;5;87mp6[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:022: Error: call to predicate [38;5;87m`det_errors_cc.p2'/2[39;49m with
|
||
det_errors_cc.m:022: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:022: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:023: Call to [38;5;87mp3[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:024: Call to [38;5;87mp4[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:025: Call to [38;5;87mp5[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:026: Call to [38;5;87mp6[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:023: Error: call to predicate [38;5;87m`det_errors_cc.p3'/2[39;49m with
|
||
det_errors_cc.m:023: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:023: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:024: Call to [38;5;87mp4[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:025: Call to [38;5;87mp5[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:026: Call to [38;5;87mp6[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:024: Error: call to predicate [38;5;87m`det_errors_cc.p4'/2[39;49m with
|
||
det_errors_cc.m:024: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:024: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:025: Call to [38;5;87mp5[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:026: Call to [38;5;87mp6[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:025: Error: call to predicate [38;5;87m`det_errors_cc.p5'/2[39;49m with
|
||
det_errors_cc.m:025: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:025: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:026: Call to [38;5;87mp6[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:031: Error: call to predicate [38;5;87m`det_errors_cc.p3'/2[39;49m with
|
||
det_errors_cc.m:031: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:031: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:032: Call to [38;5;87mp4[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:033: Unification of [38;5;87m`C'[39;49m with [38;5;87m10[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:034: Unification of [38;5;87m`B'[39;49m and [38;5;87m`C'[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:032: Error: call to predicate [38;5;87m`det_errors_cc.p4'/2[39;49m with
|
||
det_errors_cc.m:032: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:032: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:033: Unification of [38;5;87m`C'[39;49m with [38;5;87m10[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:034: Unification of [38;5;87m`B'[39;49m and [38;5;87m`C'[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:040: Error: call to predicate [38;5;87m`det_errors_cc.p3'/2[39;49m with
|
||
det_errors_cc.m:040: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:040: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:042: [38;5;87mFail goal[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:050: Error: call to predicate [38;5;87m`det_errors_cc.p2'/2[39;49m with
|
||
det_errors_cc.m:050: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:050: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:051: [38;5;87mNegated goal[39;49m [38;5;203mcan fail.[39;49m
|
||
det_errors_cc.m:056: Error: call to predicate [38;5;87m`det_errors_cc.p3'/2[39;49m with
|
||
det_errors_cc.m:056: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:056: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:058: [38;5;87mThe higher order call to the predicate variable `P'[39;49m [38;5;203mcan[39;49m
|
||
det_errors_cc.m:058: [38;5;203mfail.[39;49m
|
||
det_errors_cc.m:063: Error: call to predicate [38;5;87m`det_errors_cc.p1'/2[39;49m with
|
||
det_errors_cc.m:063: determinism `cc_nondet' [38;5;203moccurs in a context which[39;49m
|
||
det_errors_cc.m:063: [38;5;203mrequires all solutions.[39;49m
|
||
det_errors_cc.m:074: The [38;5;87mswitch on `C'[39;49m is [38;5;203mincomplete.[39;49m
|