mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
compiler/typecheck_errors.m:
Improve diagnostics for some type errors in two separate ways.
First, when printing an error message for a type mismatch,
replace messages of the form
... has type T1,
expected type was T2
with messages of the form
... has type
T1,
expected type was
T2.
This way, the types both (a) stand out from the rest of the message,
and (b) any corresponding parts will line up, making discrepancies
easier to see.
Second, avoid messages of the form
... has type `some [T] T'
expected type was `some [T] T'.
which can be both baffling and infuriating, by including the variable
numbers of the type variables if this is needed to make two different
types *visibly* different, yielding messages such as
... has type
`some [T_2] T2',
expected type was
`some [T_3] T3'.
which can still be baffling, in the absence of any info about where T_2
and T_3 came from, but at least should not be infuriating, since it
*does* show a difference between actual and expected.
compiler/error_util.m:
Provide the infrastructure for the second part, by letting callers
control how type variables are printed.
tests/invalid/actual_expected.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/coerce_ambig.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/foreign_procs_exist_type.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
Expect the updated error messages.