diff: new test case

Fergus Henderson fjh at cs.mu.oz.au
Sat Aug 16 01:48:07 AEST 1997


Estimated hours taken: 0.25

tests/invalid/Mmake:
tests/invalid/func_errors.m:
tests/invalid/func_errors.err_exp:
	New test case to check that we correctly report errors
	for certain invalid function declarations.
	(Mercury 0.6 failed this test case.)

-----------------------------------------------------------------------------
tests/invalid/func_errors.m
-----------------------------------------------------------------------------
:- module func_errors.

:- interface.
:- import_module int.

% it is an error to declare determinism but not modes,
% or to only declare some of the modes

:- func foo(int, int) = int is semidet.
:- func bar(int::in, int) = int is semidet.
:- func baz(int::in, int::in) = int is semidet.
:- func quux(int, int) = (int::out) is semidet.

:- func ok(int::in, int::in) = (int::out) is semidet.

:- pred p(int, int) is semidet.
:- mode p(in, in) is semidet.
:- pred q(int::in, int) is semidet.

:- implementation.

% foo(X, Y) = X + Y :- X > 0.
% bar(X, Y) = X + Y :- X > 0.
% baz(X, Y) = X + Y :- X > 0.
% quux(X, Y) = X + Y :- X > 0.

p(X, Y) :- X > Y.
% q(X, Y) :- X > Y.

ok(X, Y) = X + Y :- X > 0.

-----------------------------------------------------------------------------
tests/invalid/func_errors.err_exp
-----------------------------------------------------------------------------
func_errors.m:009: Error: function declaration specifies a determinism but does not specify the mode: foo(int, int).
func_errors.m:010: Error: some but not all arguments have modes: bar(int :: in, int).
func_errors.m:011: Error: function arguments have modes, but function result doesn't: baz(int :: in, int :: in).
func_errors.m:012: Error: function result has mode, but function arguments don't: quux(int, int).
func_errors.m:018: Error: some but not all arguments have modes: q(int :: in, int).
For more information, try recompiling with `-E'.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list