[m-dev.] For review: Fix inappropriate warning message for purity markers.

Peter Schachte pets at students.cs.mu.oz.au
Tue Jan 6 15:31:59 AEDT 1998


On Sat, 13 Dec 1997, Fergus Henderson wrote:

> Does the code in prog_io_goal report an error for `impure call(P)',
> as in the following example?
> 
> 	:- impure pred p(pred::(pred is semidet)) is semidet.
> 	p(P) :- 
> 		impure call(P).

The new test case:

   :- impure pred e14(pred).
   :- mode e14((pred is semidet)) is semidet.

   e14(P) :- impure call(P).

gives these messages:

   purity_nonsense.m:018: Warning: unnecessary `impure' marker.
   purity_nonsense.m:018:   Higher-order goals are always pure.
   purity_nonsense.m:015: In predicate `purity_nonsense:e14/1':
   purity_nonsense.m:015:   warning: declared `impure' but actually pure.
   purity_nonsense.m:015: Error: no mode declaration for predicate `purity_nonsense:e14/1'.

Is that good enough?  I don't know where the last message came from, any
idea?  Is it acceptable?

On the subject of bogus error messages, the code:

   e12 :- impure (\+ impure imp).

Gives this explosion of nonsense:

   purity_nonsense.m:012: In clause for predicate `purity_nonsense:e12/0':
   purity_nonsense.m:012:   in argument 1 of call to predicate `impure/1':
   purity_nonsense.m:012:   error: the language construct \+/1 should be
   purity_nonsense.m:012:   used as a goal, not as an expression.
   purity_nonsense.m:012: In clause for predicate `purity_nonsense:e12/0':
   purity_nonsense.m:012:   in argument 1 of call to predicate `impure/1':
   purity_nonsense.m:012:   in argument 1 of functor `\+/1':
   purity_nonsense.m:012:   error: the language construct impure/1 should be
   purity_nonsense.m:012:   used as a goal, not as an expression.
   purity_nonsense.m:012: In clause for predicate `purity_nonsense:e12/0':
   purity_nonsense.m:012:   in argument 1 of call to predicate `impure/1':
   purity_nonsense.m:012:   in argument 1 of functor `\+/1':
   purity_nonsense.m:012:   in argument 1 of functor `impure/1':
   purity_nonsense.m:012:   error: undefined symbol `imp/0'.
   purity_nonsense.m:012: In clause for predicate `purity_nonsense:e12/0':
   purity_nonsense.m:012:   error: `impure' marker in an inappropriate place.

It gets to the point at the end, but everything up to that is just
confusing.  I have no idea how to fix this.


> Your fix looks fine, but adding a regression test would not be a
> bad idea.

Done.


-Peter Schachte			| Opportunities multiply as they are seized.
pets at cs.mu.OZ.AU		| -- Sun Tzu 
http://www.cs.mu.oz.au/~pets/	| 
PGP key available on request	| 




More information about the developers mailing list