[mercury-users] Unique mode problem: what's the difference?
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Nov 17 04:07:24 AEDT 1999
On 16-Nov-1999, Ralph Becket <rbeck at microsoft.com> wrote:
> I have a bug in some code using mostly unique modes (it's a term
> unifier.) I'm not entirely sure what is going wrong...
> unify(T1, free, _T2, functor(Name2, Arity2, Args2)) -->
> \+ occurs(T1, Args2),
> tr_store__set_mutvar(T1, functor(Name2, Arity2, Args2)).
>
> I get the following error report
...
> logic.m:077: In clause for `unify(in, in, in, in, mdi, muo)':
> logic.m:077: in argument 3 of call to predicate `logic:occurs/4':
> logic.m:077: unique-mode error: the called procedure would clobber
> logic.m:077: its argument, but variable `DCG_0' is still live.
At first glance, that one looks like a bug in the compiler's
mode analysis of mostly-unique modes. The compiler is being
overly conservative in its analysis.
> At first blush it seems DCG0 is being destroyed in the condition of the if
> by the call to occurs/4 -
Yes, that's what the compiler thinks...
> but that occurs in a negated context, so surely it
> isn't destroyed?
You are correct, and the compiler ought to take this into account.
> If I rewrite the offending clause to be
>
> unify(T1, free, _T2, functor(Name2, Arity2, Args2)) -->
> ( if occurs(T1, Args) then
> { fail }
> else
> tr_store__set_mutvar(T1, functor(Name2, Arity2, Args2))
> ).
>
> then the error message goes away.
Great -- in that case, please use that as a work-around for now.
P.S.
I've managed to reproduce the problem here, so there is no need
for you to send a bug report.
--
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.
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list