mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 21:03:53 +00:00
compiler/typecheck_errors.m:
When we report a mismatch between the actual and expected types,
we print both types. When both these types are big, doing a "visual diff"
between the two can be hard, which is why, for a while now, we have had
code to print the diffs between the two types. However, the code computing
this diff had a bug. It detected and reported situations in which the
actual and expected types had, in the same position, the same type
constructor name but with two different arities, but ignored situations
in the type constructed differed in their names, which is a much more
common problem. Fix this.
When we report a mismatch between the actual and expected types,
we print the types themselves colored incorrect and correct respectively.
But when we diagnosed the sources of the difference, we printed
only the report of the mismatch using the incorrect color, and printed
the mismatched actual and expected entities using the "inconsistent" color.
Fix this.
compiler/typecheck_error_type_assign.m:
When the difference between actual and expected types occurs even when
builtin qualifiers have been stripped type names in both, record the
types so stripped not just in the format_pieces representations of the
types, but the types themselves. This avoids the need for new code
in typecheck_errors.m to consider the same issue.
compiler/error_spec.m:
Minor improvements in comments.
tests/invalid/actual_expected.err_exp:
tests/invalid/arith_wrong_module.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/fbnf.err_exp:
tests/invalid/higher_order_mode_mismatch.err_exp:
tests/invalid/type_diff.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 diagnostics.
45 lines
2.7 KiB
Plaintext
45 lines
2.7 KiB
Plaintext
arith_wrong_module.m:022: In clause for predicate `test_func'/3:
|
||
arith_wrong_module.m:022: type error in unification of variable `C'
|
||
arith_wrong_module.m:022: and functor `+'/2.
|
||
arith_wrong_module.m:022: [38;5;87mVariable `C'[39;49m has type
|
||
arith_wrong_module.m:022: [38;5;203muint32,[39;49m
|
||
arith_wrong_module.m:022: [38;5;87mfunctor `+'/2[39;49m has type
|
||
arith_wrong_module.m:022: [38;5;40m`+'(int, int): int.[39;49m
|
||
arith_wrong_module.m:022: Note that operations on values of type `uint32' are
|
||
arith_wrong_module.m:022: available only if module [38;5;226m`uint32' is imported.[39;49m
|
||
arith_wrong_module.m:025: In clause for predicate `test_pred'/3:
|
||
arith_wrong_module.m:025: in call to predicate `int.pow'/3:
|
||
arith_wrong_module.m:025: in argument 1:
|
||
arith_wrong_module.m:025: [38;5;87mvariable `A'[39;49m has type
|
||
arith_wrong_module.m:025: [38;5;203mint16,[39;49m
|
||
arith_wrong_module.m:025: expected type was
|
||
arith_wrong_module.m:025: [38;5;40mint;[39;49m
|
||
arith_wrong_module.m:025: in argument 2:
|
||
arith_wrong_module.m:025: [38;5;87mvariable `B'[39;49m has type
|
||
arith_wrong_module.m:025: [38;5;203muint16,[39;49m
|
||
arith_wrong_module.m:025: expected type was
|
||
arith_wrong_module.m:025: [38;5;40mint;[39;49m
|
||
arith_wrong_module.m:025: in argument 3:
|
||
arith_wrong_module.m:025: [38;5;87mvariable `C'[39;49m has type
|
||
arith_wrong_module.m:025: [38;5;203mint16,[39;49m
|
||
arith_wrong_module.m:025: expected type was
|
||
arith_wrong_module.m:025: [38;5;40mint.[39;49m
|
||
arith_wrong_module.m:025: Note that operations on values of types `int16'
|
||
arith_wrong_module.m:025: `uint16' are available only if modules [38;5;226m`int16'[39;49m and
|
||
arith_wrong_module.m:025: [38;5;226m`uint16' are imported.[39;49m
|
||
arith_wrong_module.m:028: In clause for predicate `game_loop'/4:
|
||
arith_wrong_module.m:028: in unification of [38;5;87mvariable `Diff'[39;49m
|
||
arith_wrong_module.m:028: and term [38;5;87m`(End - Start)':[39;49m
|
||
arith_wrong_module.m:028: type error in arguments of functor `-'/2.
|
||
arith_wrong_module.m:028: [38;5;87mArgument 1 (End)[39;49m has type
|
||
arith_wrong_module.m:028: [38;5;203mint64,[39;49m
|
||
arith_wrong_module.m:028: expected type was
|
||
arith_wrong_module.m:028: [38;5;40mint.[39;49m
|
||
arith_wrong_module.m:028: [38;5;87mArgument 2 (Start)[39;49m has type
|
||
arith_wrong_module.m:028: [38;5;203mint64,[39;49m
|
||
arith_wrong_module.m:028: expected type was
|
||
arith_wrong_module.m:028: [38;5;40mint.[39;49m
|
||
arith_wrong_module.m:028: Note that operations on values of type `int64' are
|
||
arith_wrong_module.m:028: available only if module [38;5;226m`int64' is imported.[39;49m
|
||
For more information, recompile with `-E'.
|