diff: work-around for intermodule optimization bug

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Feb 15 03:18:38 AEDT 1998


On 15-Feb-1998, I wrote:

> When compiling with intermodule optimization enabled,
> private equivalence types in imported modules are visible,
> so previously abstract types may become concrete.
> This happens before semantic checking, so it affects whether
> or not the compiler reports type errors.  Clearly it can
> make type errors go away.  Less obvious is the fact that it
> can also introduce ambiguity errors into code that would
> otherwise be ambiguity-free. 
> 
> This bug causes the compiler to fail to bootstrap when compiled
> with options `--intermodule-optimization -O4'.

Hence the following change.

compiler/polymorphism.m:
	Add an explicit type qualification, to work around a
	bug with intermodule optimization that causes a spuriou
	ambiguity errors when the compiler is bootstapped with
	`-O4 --intermodule-optimization'.

cvs diff  compiler/polymorphism.m
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.127
diff -u -r1.127 polymorphism.m
--- polymorphism.m	1998/02/12 01:17:39	1.127
+++ polymorphism.m	1998/02/14 15:55:52
@@ -2246,7 +2246,11 @@
 				Index0::in, Index::out] is det,
 		(
 			Elem = Elem0 - Index0,
-			Index is Index0 + 1
+			Index is Index0 + 1,
+			% the following call is a work-around for a compiler
+			% bug with intermodule optimization: it is needed to
+			% resolve a type ambiguity
+			is_pair(Elem)
 		)),
 	list__map_foldl(MakeIndex, ClassTypeVars0, ClassTypeVars, First, _),
 		
@@ -2278,6 +2282,9 @@
 		VarTypes1, VarTypes,
 		ExtraHeadVars1, ExtraHeadVars,
 		TypeClassInfoMap1, TypeClassInfoMap).
+
+:- pred is_pair(pair(_, _)::in) is det.
+is_pair(_).
 
 :- pred polymorphism__new_typeclass_info_var(varset, map(var, type), 
 		string, var, 

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