diff: lambda.m bug fix

Fergus Henderson fjh at cs.mu.oz.au
Tue May 27 03:03:12 AEST 1997


compiler/lambda.m:
	Fix a buggy optimization: the code was assuming that the
	argument variables to a procedure call are all distinct, but
	that is not necessarily the case -- although they are made
	distinct for type checking and mode analysis, excess assignment
	elimination (which is done by simplify.m) can reintroduce
	duplicate args.  This fixes a "variable not found" bug.

(The regression test for this one still doesn't work, due to some
additional as-yet-unsolved bug.  I'll add it when I've fixed that
one too.)

Index: lambda.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/lambda.m,v
retrieving revision 1.26
diff -u -r1.26 lambda.m
--- lambda.m	1997/05/05 11:17:09	1.26
+++ lambda.m	1997/05/26 16:02:22
@@ -241,7 +241,7 @@
 	% This optimization is only valid if the modes of the Xi are
 	% input, since only input arguments can be curried.
 	% It's also only valid if all the inputs in the Yi precede the
-	% outputs.
+	% outputs.  It's also not valid if any of the Xi are in the Yi.
 
 	LambdaGoal = _ - LambdaGoalInfo,
 	goal_info_get_nonlocals(LambdaGoalInfo, NonLocals0),
@@ -251,6 +251,13 @@
 		LambdaGoal = call(PredId0, ProcId0, CallVars,
 					_, _, PredName0) - _,
 		list__remove_suffix(CallVars, Vars, InitialVars),
+	
+		% check that none of the variables that we're trying to
+		% use as curried arguments are lambda-bound variables
+		\+ (
+			list__member(InitialVar, InitialVars),
+			list__member(InitialVar, Vars)
+		),
 
 		module_info_pred_proc_info(ModuleInfo0, PredId0, ProcId0, _,
 			Call_ProcInfo),

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