[m-dev.] mode/determinism analysis bug with user-defined equality types

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 30 01:02:55 AEDT 2000


The attached program gets a spurious mode error in an automatically
generated unification predicate.

	$ mmc fld2
	fld2.m:018: In clause for `'__Unify__'((unique(fld2:mkfoo(unique(1), unique(2))) -> not_reached), (unique(fld2:mkfoo(unique(3), unique(4))) -> not_reached))':
	fld2.m:018:   mode error: argument 1 did not get sufficiently instantiated.
	fld2.m:018:   Final instantiatedness of `HeadVar__1' was `bound(fld2:mkfoo(bound(1), bound(2)))',
	fld2.m:018:   expected final instantiatedness was `not_reached'.
	fld2.m:005: In `main(di, uo)':
	fld2.m:005:   warning: determinism declaration could be tighter.
	fld2.m:005:   Declared `cc_multi', inferred `erroneous'.
	fld2.m:020: Warning: the condition of this if-then-else cannot fail.
	For more information, try recompiling with `-E'.

It looks like the compiler is for some reason wrongly inferring in mode
analysis that this unification cannot succeed.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
-------------- next part --------------
:- module fld2.
:- interface.
:- import_module io.

:- pred main(state::di, state::uo) is cc_multi.

:- implementation.
:- import_module std_util.

:- type foo ---> mkfoo(int, int) where equality is foo_eq.

:- pred foo_eq(foo::in, foo::in) is semidet.
foo_eq(mkfoo(_, _), mkfoo(_, _)) :- semidet_succeed.

main -->
	{ Foo = mkfoo(1, 2) },
	{ Quux = mkfoo(3, 4) },
	( { Foo = Quux } ->
		print("Foo = Quux"), nl
	;
		print("Foo \\= Quux"), nl
	),
	nl.



More information about the developers mailing list