[m-dev.] for review: fix existential types bug

Simon Taylor stayl at cs.mu.OZ.AU
Mon Oct 25 10:14:10 AEST 1999


Estimated hours taken: 0.25

Fix a spurious mode error for constructions involving
existentially typed constructors.

compiler/polymorphism.m:
	Add the type-info variables added for the existential
	type variables of a constructor to the non-locals of
	the construction.

Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.173
diff -u -u -r1.173 polymorphism.m
--- polymorphism.m	1999/10/15 03:45:01	1.173
+++ polymorphism.m	1999/10/20 08:39:42
@@ -1309,8 +1309,11 @@
 			IsConstruction, ActualArgTypes, TypeOfX, Context,
 			ExtraVars, ExtraGoals, PolyInfo0, PolyInfo),
 		list__append(ExtraVars, ArgVars0, ArgVars),
+		goal_info_get_nonlocals(GoalInfo0, NonLocals0),
+		set__insert_list(NonLocals0, ExtraVars, NonLocals),
+		goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo),
 		Unify = unify(X0, functor(ConsId, ArgVars), Mode0,
-				Unification0, UnifyContext) - GoalInfo0,
+				Unification0, UnifyContext) - GoalInfo,
 		list__append(ExtraGoals, [Unify], GoalList),
 		conj_list_to_goal(GoalList, GoalInfo0, Goal)
 	;
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.43
diff -u -u -r1.43 Mmakefile
--- Mmakefile	1999/09/21 07:26:09	1.43
+++ Mmakefile	1999/10/25 00:01:41
@@ -41,6 +41,7 @@
 	empty_bound_inst_list.m \
 	empty_switch.m \
 	error.m \
+	existential_cons.m \
 	explicit_quant.m \
 	fail_ite.m \
 	followcode_det_problem.m \
Index: tests/valid/existential_cons.m
===================================================================
RCS file: existential_cons.m
diff -N existential_cons.m
--- /dev/null	Mon Oct 25 10:09:06 1999
+++ existential_cons.m	Mon Oct 25 10:00:54 1999
@@ -0,0 +1,20 @@
+% The ROTD of 25/10/1999 gave a spurious mode error for this
+% test case because the type-info argument of the cons_id was not being
+% put in the non-locals of the construction.
+:- module existential_cons.
+
+:- interface.
+
+:- type exist_cons
+	---> some[T] exist_cons(a::int, b::T, c::int).
+
+:- pred construct_exist_cons(exist_cons::out) is det.
+
+:- implementation.
+
+construct_exist_cons(ExistCons) :-
+	A = 1,
+	X = 'b',
+	C = 2,
+	ExistCons = 'new exist_cons'(A, X, C).
+
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list