[m-dev.] for review: fix warnings with no context

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Jun 12 12:59:49 AEST 1998


On 11-Jun-1998, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> Fix a bug reported by Philip Dart where "this disjunct cannot succeed"
> warnings for predicates using sub-typing in modes were being output
> without a context.

Thanks Simon, that looks good.

> compiler/simplify.m
> 	Only report --warn-simple-code messages which occur for
> 	all modes of a predicate - this avoids spurious 
> 	"this disjunct cannot succeed" warnings for sub-typing.

The trouble with this change is that although many of the
warnings enabled by --warn-simple-code should only apply
if they occur for all modes, I think some of them -- in particular
the warning about infinite recursion -- should perhaps apply
if even if they occur only for some of the modes.

For example, if I write
	
	:- type node ---> a ; b ; c.

        :- pred parent(node, node).
        :- mode parent(in, out).
        :- mode parent(out, in).
	parent(a, b).
	parent(b, c).
	parent(a, c).

	:- pred node(node).
	:- mode node(out).
	node(a).
	node(b).
	node(c).

        :- pred anc(node, node).
        :- mode anc(in, out).
        :- mode anc(out, in).
        anc(X, X) :-
		node(X).
        anc(X, Z) :-
                parent(X, Y),
                anc(Y, Z).

then anc/2 is fine (well, assuming the parent/2 relation is
acyclic!) in the `in, out' mode, but loops in the `out, in' mode.
I'd like to get a warning.

Thus, I think simplify.m really need to keep two sets of warnings,
one for warnings which apply if they occur in any mode, and
one for warnings that apply only if they occur in every mode.

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