mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 19:03:45 +00:00
compiler/typecheck_errors.m:
Improve the diagnostics we generate for mismatches between actual and
expected types. If the mismatch was between a single actual type and
a single expected type, we already printed a message whose format
was specialized for that case, but in every other case, we fell back
to a more general but less readable error message template. Improve on this
by splitting the task into two halves, one for the actual type(s) and one
for the expected type(s), each of which generates simpler text if
there is only one such type.
Separate the actual type part of the diagnostic from the expected type part
using a semicolon instead of a comma, because we now use commas to
separate multiple actual types from each other, and multiple expected
types from each other.
Don't insist on putting a newline after the "type error:" part of the
diagnostic.
Do all of the above in just one predicate, factoring out code that
used to be duplicated.
Delete a function that has never been used. (I added it around 2008
for later use by a student working on software transactional memory,
but that use never happened.) This used to contain a third copy
of the code that was factored out.
For functions that used to take both a typecheck_info and a
type_error_clause_context, delete the latter argument, since the caller
invariably took it out of the typecheck_info that it also passed.
compiler/typecheck.m:
Don't pass now-unneeded type_error_clause_contexts.
compiler/typecheck_error_type_assign.m:
Fix typo in a field name.
tests/invalid/abstract_eqv.err_exp:
tests/invalid/actual_expected.err_exp:
tests/invalid/actual_more_expected.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/fbnf.err_exp:
tests/invalid/foreign_procs_exist_type.err_exp:
tests/invalid/higher_order_mode_mismatch.err_exp:
tests/invalid/integral_constant_no_suffix.err_exp:
tests/invalid/method_impl.err_exp:
tests/invalid/mixed_up_streams.err_exp:
tests/invalid/try_bad_params.err_exp:
tests/invalid/type_diff.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/types2.err_exp:
tests/invalid_nodepend/errors2.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:
Update expected error messages.
163 lines
7.1 KiB
Plaintext
163 lines
7.1 KiB
Plaintext
errors2.m:005: Warning: the interface of module `errors2' does not export
|
|
errors2.m:005: anything.
|
|
errors2.m:005: To be useful, a module should export something. A file should
|
|
errors2.m:005: contain at least one declaration other than `:- import_module'
|
|
errors2.m:005: in its interface section(s). This would normally be a
|
|
errors2.m:005: `:- pred' or `:- func' declaration, or a `:- type', `:- inst',
|
|
errors2.m:005: `:- mode', `:- typeclass' or `:- instance' definition.
|
|
errors2.m:009: Error: module `errors2' should start with either an
|
|
errors2.m:009: `:- interface' or an `:- implementation' declaration.
|
|
errors2.m:009: The following assumes that the missing declaration is an
|
|
errors2.m:009: `:- implementation' declaration.
|
|
errors2.m:009: Error: no clauses for predicate `bind_type_param'/2.
|
|
errors2.m:011: Error: clause for predicate `bind_type_param'/1
|
|
errors2.m:011: without corresponding `:- pred' declaration.
|
|
errors2.m:011: However, a predicate of that name does exist with arity 2.
|
|
errors2.m:011: Inferred :- pred bind_type_param(int).
|
|
errors2.m:011: The argument list difference from the arity 2 version is
|
|
errors2.m:011: pred(
|
|
errors2.m:011: - V_1,
|
|
errors2.m:011: - V_2
|
|
errors2.m:011: + int
|
|
errors2.m:011: )
|
|
errors2.m:025: Error: no clauses for predicate `produce_string'/1.
|
|
errors2.m:027: Error: no clauses for predicate `expect_int'/1.
|
|
errors2.m:033: In clause for predicate `type_error'/0:
|
|
errors2.m:033: in argument 1 of call to predicate `errors2.expect_int'/1:
|
|
errors2.m:033: type error: variable `X' has type
|
|
errors2.m:033: string;
|
|
errors2.m:033: expected type was
|
|
errors2.m:033: int.
|
|
errors2.m:033: The partial type assignment was:
|
|
errors2.m:033: X_1: string
|
|
errors2.m:040: In clause for predicate `type_error_2'/0:
|
|
errors2.m:040: type error in unification of variable `X'
|
|
errors2.m:040: and variable `Y'.
|
|
errors2.m:040: `X' has type
|
|
errors2.m:040: string,
|
|
errors2.m:040: `Y' has type
|
|
errors2.m:040: int.
|
|
errors2.m:040: The partial type assignment was:
|
|
errors2.m:040: X_1: string
|
|
errors2.m:040: Y_2: int
|
|
errors2.m:047: In clause for predicate `type_error_3'/0:
|
|
errors2.m:047: in argument 1 of call to predicate `errors2.expect_int'/1:
|
|
errors2.m:047: type error: variable `Y' has type
|
|
errors2.m:047: string;
|
|
errors2.m:047: expected type was
|
|
errors2.m:047: int.
|
|
errors2.m:047: The partial type assignment was:
|
|
errors2.m:047: X_1: string
|
|
errors2.m:047: Y_2: string
|
|
errors2.m:062: In clause for predicate `type_error_4'/0:
|
|
errors2.m:062: warning: variable `X' occurs only once in this scope.
|
|
errors2.m:062: In clause for predicate `type_error_4'/0:
|
|
errors2.m:062: in argument 3 of functor `foo_functor/3':
|
|
errors2.m:062: type error in unification of argument
|
|
errors2.m:062: and constant `1.0'.
|
|
errors2.m:062: argument has type
|
|
errors2.m:062: string,
|
|
errors2.m:062: constant `1.0' has type
|
|
errors2.m:062: float.
|
|
errors2.m:062: The partial type assignment was:
|
|
errors2.m:062: Y_1: int
|
|
errors2.m:062: X_2: errors2.foo_type
|
|
errors2.m:062: V_3: character
|
|
errors2.m:062: V_4: string
|
|
errors2.m:072: In clause for predicate `type_error_5'/0:
|
|
errors2.m:072: warning: variable `X' occurs only once in this scope.
|
|
errors2.m:072: In clause for predicate `type_error_5'/0:
|
|
errors2.m:072: in argument 3 of functor `foo_functor/3':
|
|
errors2.m:072: type error in unification of argument
|
|
errors2.m:072: and constant `1.0'.
|
|
errors2.m:072: argument has type
|
|
errors2.m:072: string,
|
|
errors2.m:072: constant `1.0' has type
|
|
errors2.m:072: float.
|
|
errors2.m:072: The partial type assignment was:
|
|
errors2.m:072: Y_1: character
|
|
errors2.m:072: X_2: errors2.foo_type
|
|
errors2.m:072: V_3: int
|
|
errors2.m:072: V_4: string
|
|
errors2.m:078: In clause for predicate `type_error_6'/0:
|
|
errors2.m:078: warning: variable `X' occurs only once in this scope.
|
|
errors2.m:078: In clause for predicate `type_error_6'/0:
|
|
errors2.m:078: in argument 3 of functor `bar_functor/3':
|
|
errors2.m:078: type error in unification of argument
|
|
errors2.m:078: and constant `1.0'.
|
|
errors2.m:078: argument has type
|
|
errors2.m:078: string,
|
|
errors2.m:078: constant `1.0' has type
|
|
errors2.m:078: float.
|
|
errors2.m:078: The partial type assignment was:
|
|
errors2.m:078: Y_1: character
|
|
errors2.m:078: X_2: errors2.bar_1_type
|
|
errors2.m:078: V_3: int
|
|
errors2.m:078: V_4: string
|
|
errors2.m:083: In clause for predicate `type_error_7'/0:
|
|
errors2.m:083: warning: variable `Y' occurs only once in this scope.
|
|
errors2.m:084: In clause for predicate `type_error_7'/0:
|
|
errors2.m:084: warning: variables `A, B, Z' occur only once in this scope.
|
|
errors2.m:085: In clause for predicate `type_error_7'/0:
|
|
errors2.m:085: in argument 1 of call to predicate `errors2.expect_int'/1:
|
|
errors2.m:085: type error: variable `C' has type
|
|
errors2.m:085: string;
|
|
errors2.m:085: expected type was
|
|
errors2.m:085: int.
|
|
errors2.m:085: The possible partial type assignments were:
|
|
errors2.m:085: Type assignment 1:
|
|
errors2.m:085: Y_1: errors2.foo
|
|
errors2.m:085: Z_2: errors2.bar_1_type
|
|
errors2.m:085: A_3: int
|
|
errors2.m:085: B_4: character
|
|
errors2.m:085: C_5: string
|
|
errors2.m:085:
|
|
errors2.m:085: Type assignment 2:
|
|
errors2.m:085: Y_1: character
|
|
errors2.m:085: Z_2: errors2.bar_1_type
|
|
errors2.m:085: A_3: int
|
|
errors2.m:085: B_4: character
|
|
errors2.m:085: C_5: string
|
|
errors2.m:085:
|
|
errors2.m:085: Type assignment 3:
|
|
errors2.m:085: Y_1: errors2.foo
|
|
errors2.m:085: Z_2: errors2.bar_2_type
|
|
errors2.m:085: A_3: character
|
|
errors2.m:085: B_4: int
|
|
errors2.m:085: C_5: string
|
|
errors2.m:085:
|
|
errors2.m:085: Type assignment 4:
|
|
errors2.m:085: Y_1: character
|
|
errors2.m:085: Z_2: errors2.bar_2_type
|
|
errors2.m:085: A_3: character
|
|
errors2.m:085: B_4: int
|
|
errors2.m:085: C_5: string
|
|
errors2.m:092: In clause for predicate `type_error_8'/0:
|
|
errors2.m:092: error: undefined predicate `from_char_list'/2.
|
|
errors2.m:092: That predicate is defined in module `string', which does not
|
|
errors2.m:092: have an `:- import_module' declaration.
|
|
errors2.m:092: Note that symbols defined in modules accessed via
|
|
errors2.m:092: `:- use_module' declarations must always be fully module
|
|
errors2.m:092: qualified.
|
|
errors2.m:092: In clause for predicate `type_error_8'/0:
|
|
errors2.m:092: in argument 1 of call to predicate `from_char_list'/2:
|
|
errors2.m:092: error: undefined symbol `[]'/0.
|
|
errors2.m:092: That symbol is defined in module `list', which does not have
|
|
errors2.m:092: an `:- import_module' declaration.
|
|
errors2.m:100: In clause for predicate `type_error_9'/0:
|
|
errors2.m:100: type error in unification of variable `X'
|
|
errors2.m:100: and variable `Y'.
|
|
errors2.m:100: `X' has type
|
|
errors2.m:100: {int, string, character},
|
|
errors2.m:100: `Y' has type
|
|
errors2.m:100: {string, character, int}.
|
|
errors2.m:100: The partial type assignment was:
|
|
errors2.m:100: X_1: {int, string, character}
|
|
errors2.m:100: Y_2: {string, character, int}
|
|
errors2.m:100: V_3: int
|
|
errors2.m:100: V_4: string
|
|
errors2.m:100: V_5: character
|
|
errors2.m:100: V_6: string
|
|
errors2.m:100: V_7: character
|
|
errors2.m:100: V_8: int
|