mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-22 21:03:53 +00:00
compiler/mode_errors.m:
When generating an error message for a bad higher order inst,
print the specific cause of the mismatch, instead of just
"actual inst is X, expected inst was Y".
compiler/modecheck_call.m:
Change the code that generates that error to record the specific cause
in the mode_error structure of the error.
tests/invalid/higher_order_mode_mismatch.{m,err_exp}:
Add a new test case for the specific causes that other test cases
don't already cover. (As it happens, most of those causes can't be
caught by mode analysis because typechecking reports them first,
but it did so in ways that could be improved. Hence the change to
typecheck_errors.m and most of the .err_exp files below.)
tests/invalid/Mmakefile:
Enable the new test case.
compiler/typecheck_errors.m:
Instead of generating output of the form
<something> has type `abc',
expected type was `def'
generate output of the form
<something> has type
abc,
expected type was
def
The indentation directs the eye to the differences that matter,
and automatically lines up any corresponding parts of the actual
and expected types. It also replaces the quotes as a method
of separating the types being referred to from their surroundings.
tests/invalid/abstract_eqv.err_exp:
tests/invalid/actual_expected.err_exp:
tests/invalid/anys_in_negated_contexts.err_exp:
tests/invalid/arg_permutation.err_exp:
tests/invalid/bad_statevar_bad_context.err_exp:
tests/invalid/bug197.err_exp:
tests/invalid/comparison.err_exp:
tests/invalid/error_in_list.err_exp:
tests/invalid/ext_type.err_exp:
tests/invalid/ext_type_bug.err_exp:
tests/invalid/foreign_procs_exist_type.err_exp:
tests/invalid/getopt_old.err_exp:
tests/invalid/ho_type_arity_bug.err_exp:
tests/invalid/ho_type_mode_bug.err_exp:
tests/invalid/illtyped_compare.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/mpj1.err_exp:
tests/invalid/mpj4.err_exp:
tests/invalid/no_method.err_exp:
tests/invalid/nullary_ho_func_error.err_exp:
tests/invalid/overloading.err_exp:
tests/invalid/record_syntax_errors.err_exp:
tests/invalid/try_bad_params.err_exp:
tests/invalid/type_error_ambiguous.err_exp:
tests/invalid/type_error_in_arg.err_exp:
tests/invalid/type_mismatch.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/user_field_access_decl_override2.err_exp:
tests/invalid_nodepend/errors2.err_exp:
tests/invalid_purity/impure_func_t5.err_exp:
tests/invalid_purity/impure_pred_t1.err_exp:
tests/invalid_purity/impure_pred_t1_fixed.err_exp:
tests/invalid_purity/impure_pred_t2.err_exp:
tests/invalid_purity/purity_nonsense2.err_exp:
tests/invalid_purity/purity_type_error.err_exp:
Expect the updated error messages.
tests/invalid/ho_type_mode_bug.m:
Update obsolete comments.
41 lines
1.2 KiB
Mathematica
41 lines
1.2 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This was intended as a test of the code that prints out higher order
|
|
% mode mismatches other than arity mismatches (those errors are tested by
|
|
% other test cases). However, all these errors are caught by the typechecker
|
|
% first.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module higher_order_mode_mismatch.
|
|
|
|
:- interface.
|
|
|
|
:- pred test_1(pred(int, int, int)::in(pred(in, in, out) is det),
|
|
int::in, int::out) is det.
|
|
:- pred test_2((func(int, int) = int)::in,
|
|
int::in, int::out) is det.
|
|
:- pred test_3((func(int, int) = int)::in(func(in, in) = out is det),
|
|
int::in, int::out) is det.
|
|
:- pred test_4(int::in, int::in, int::out) is det.
|
|
:- pred test_5(int::in, int::in, int::out) is det.
|
|
|
|
:- implementation.
|
|
|
|
test_1(P, In1, Out) :-
|
|
Out = P(In1, In1).
|
|
|
|
test_2(F, In1, Out) :-
|
|
F(In1, In1, Out).
|
|
|
|
test_3(F, In1, Out) :-
|
|
F(In1, In1, Out).
|
|
|
|
test_4(In1, In2, Out) :-
|
|
Out = In1(In2).
|
|
|
|
test_5(In1, In2, Out) :-
|
|
In1(In2, Out).
|