bug in handling of failure unifications

Fergus Henderson fjh at cs.mu.oz.au
Sat Aug 23 19:46:03 AEST 1997


The compiler issues a spurious warning and generates incorrect code for
the following module.  It does not correctly handle calls to implied
modes where the implied unification always fails.

	:- module bug.
	:- interface.

	:- pred bar(int::in) is failure.

	:- implementation.
	:- import_module bool.

	:- pred foo(int, bool).
	:- mode foo(in, out(bound(no))) is det.

	foo(_, no).

	bar(X) :-
		foo(X, yes).

The problem is that when it splits a call to an implied mode into
a call to a standard mode followed by a test unification, the instmap
delta on the call to the standard mode is set to `unreachable', which
is not correct.

:- mode bar(mercury_builtin:in) is failure.
bug:bar(HeadVar__1_1) :-
	% nonlocals: HeadVar__1_1
	( % conjunction
		% nonlocals: HeadVar__1_1, X_2
		HeadVar__1_1 = X_2
		% X_2 := HeadVar__1_1
		% new insts: X_2 -> ground
		,
		% nonlocals: V_3
		V_3 = bool:yes
		% V_3 := bool:yes/0
		% new insts: V_3 -> unique(bool:yes)
		,
		% nonlocals: X_2, V_3
		( % conjunction
			% nonlocals: X_2, V_4
			foo(X_2, V_4)
			% new insts: unreachable
			,
			% nonlocals: V_3, V_4
			fail
			% new insts: V_3 -> not_reached
			%            V_4 -> not_reached
		)
		% new insts: unreachable
	).
	% new insts: unreachable

-- 
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