mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 11:23:46 +00:00
NEWS:
Announce the new strictness.
compiler/add_type.m:
Classify *every* type declaration and definition as either solver or
not solver, and insist that *all* declarations and definitions of a type
have the same classification.
Improve the error messages we generate for solver/nosolver mismatches.
Avoid using add_or_replace_type_ctor_defn; use just add_type_ctor_defn
or replace_type_ctor_defn instead.
compiler/hlds_data.m:
Delete the definition of add_or_replace_type_ctor_defn.
tests/invalid/abstract_solver_type.{m,err_exp}:
tests/invalid/foreign_solver_type.{m,err_exp}:
Two new test cases to test the new error detection capabilities.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/any_mode.{m,err_exp}:
Change this existing test slightly to avoid a warning that is
completely unrelated to the test's purpose. Update the line numbers
in the expected output.
tests/valid/solver_type_bug.m:
The old code of this test now gets an error message from the new code
in add_type.m. Change it to avoid this while still testing for the
absence of the code generator error it was originally created for.
38 lines
930 B
Mathematica
38 lines
930 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module any_mode.
|
|
|
|
:- interface.
|
|
|
|
:- solver type foo
|
|
where representation is int,
|
|
ground is ground,
|
|
any is ground,
|
|
equality is eq_foo.
|
|
|
|
:- pred p(foo::(any >> ground)) is semidet.
|
|
:- pred q(foo::in) is semidet.
|
|
|
|
:- implementation.
|
|
|
|
p(X) :- q(X).
|
|
|
|
q(foo(123)).
|
|
|
|
:- pred init_foo(foo::out(any)) is det.
|
|
init_foo(foo(42)).
|
|
|
|
:- func foo(int::in) = (foo::out(any)) is det.
|
|
:- pragma promise_pure(foo/1).
|
|
foo(N) = X :-
|
|
impure X = 'representation to any foo/0'(N).
|
|
|
|
:- pred eq_foo(foo::in(any), foo::in(any)) is semidet.
|
|
:- pragma promise_pure(eq_foo/2).
|
|
eq_foo(X, Y) :-
|
|
impure RX = 'representation of any foo/0'(X),
|
|
impure RY = 'representation of any foo/0'(Y),
|
|
RX = RY.
|