diff: fix bug with simplify.m & existential types

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Aug 4 23:12:28 AEST 1998


compiler/simplify.m:
	Fix a bug: it was incorrectly optimizing away calls to
	existentially typed predicates if the call had no output
	variables.  In such cases, it should not optimize the call
	away, since the type_info is output.

	For the moment I have just disabled the optimization.
	The proper fix would be to run polymorphism.m before simplify.m
	rather than vice versa.  When we've done that, we can re-enable
	this optimization.

Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.61
diff -u -u -9 -r1.61 simplify.m
--- simplify.m	1998/06/17 05:13:53	1.61
+++ simplify.m	1998/08/04 13:01:18
@@ -301,18 +301,26 @@
 		% if --no-fully-strict,
 		% replace goals which cannot fail and have no
 		% output variables with `true'.
 		% However, we don't do this for erroneous goals,
 		% since these may occur in conjunctions where there
 		% are no producers for some variables, and the
 		% code generator would fail for these.
 		% XXX we should warn about this (if the goal wasn't `true')
 		%
+
+		% XXX this optimization is currently disabled,
+		% since it mishandles calls to existentially typed
+		% predicates. 
+		% The fix for this is to run polymorphism.m before simplify.m.
+		% When that is done, we can re-enable this optimization.
+		semidet_fail,
+
 		determinism_components(Detism, cannot_fail, MaxSoln),
 		MaxSoln \= at_most_zero,
 		goal_info_get_instmap_delta(GoalInfo0, InstMapDelta),
 		goal_info_get_nonlocals(GoalInfo0, NonLocalVars),
 		simplify_info_get_instmap(Info0, InstMap0),
 		det_no_output_vars(NonLocalVars, InstMap0, InstMapDelta,
 			DetInfo),
 		% ensure goal is pure or semipure
 		\+ goal_info_is_impure(GoalInfo0),

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