[m-dev.] Is this a Mercury bug?

Peter Schachte schachte at csse.unimelb.edu.au
Tue Mar 7 12:14:02 AEDT 2006


Hi,

I got this error message from mmc version g12-0.2.0:

    bug1.m:026: In clause for predicate `bug1.eq/2':
    bug1.m:026:   in argument 1 of call to predicate `invoke/1':
    bug1.m:026:  type error: type of argument does not match its expected
    type;
    bug1.m:026:   argument has overloaded actual/expected types {
    bug1.m:026:     (inferred) (pred),
    bug1.m:026:  (expected) (impure
    pred((store.store((propagation.pqueue_store_phantom_type))),
    (store.store((propagation.pqueue_store_phantom_type))))),
    bug1.m:026:  (inferred)
    pred((store.store((propagation.pqueue_store_phantom_type))),
    (store.store((propagation.pqueue_store_phantom_type)))),
    bug1.m:026:  (expected) (impure
    pred((store.store((propagation.pqueue_store_phantom_type))),
    (store.store((propagation.pqueue_store_phantom_type)))))
    bug1.m:026:   }.

I'm attaching the test case.

That error message seems bogus to me for two reasons.  Firstly, I
don't see why it considers the pred and func versions of eq to be
overloaded.  But if I rename one of them, or if I fix the impurity
problem the overloading probelm goes away.

But the more important problem:  why can't I pass a pure predicate
where an impure one is expected?  I'm being good, but the compiler
demands something more tawdry.

-- 
Peter Schachte              You should always go to other people's funerals;
schachte at cs.mu.OZ.AU        otherwise, they won't come to yours.
www.cs.mu.oz.au/~schachte/      -- Yogi Berra 
Phone: +61 3 8344 1338      
-------------- next part --------------
:- module bug1.
:- interface.

:- solver type fdvar.
:- pred eq(fdvar::ia, fdvar::ia) is semidet.

:- implementation.

:- import_module propagation.
:- import_module any_util.


:- solver type fdvar
	where	representation	is int,
		initialisation	is new_fdvar,
		equality	is eq.

:- pred new_fdvar(fdvar::oa) is det.
new_fdvar(V) :-
	promise_pure
	(   impure V = 'representation to any fdvar/0'(0)
	).

eq(X, Y) :-
	promise_pure
	(   impure invoke(eq(X, Y))
	).

:- pred eq(fdvar::ia, fdvar::ia, pqueue::di, pqueue::uo) is semidet.

eq(_, _, !PQ).


More information about the developers mailing list