[m-dev.] diff: fix bug in polymorphism.m

Simon Taylor stayl at cs.mu.OZ.AU
Thu Aug 24 16:00:03 AEST 2000


Estimated hours taken: 0.5

Fix a bug in the handling of typeclass methods with unconstrained
existentially typed arguments. The modes of the extra arguments
introduced by polymorphism.m were added in the wrong order,
resulting in a mode error.

compiler/polymorphism.m:
	Add the modes for type_infos before the modes of typeclass_infos,
	not the other way around.

tests/hard_coded/Mmakefile:
tests/hard_coded/typeclass_exist_method_2.m:
	Test case.


Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.193
diff -u -u -r1.193 polymorphism.m
--- compiler/polymorphism.m	2000/08/09 07:47:34	1.193
+++ compiler/polymorphism.m	2000/08/23 10:07:29
@@ -671,8 +671,9 @@
 	list__duplicate(NumUnconstrainedExistTVars, Out, ExistTypeInfoModes),
 	list__duplicate(NumUnivClassInfoVars, In, UnivTypeClassInfoModes),
 	list__duplicate(NumExistClassInfoVars, Out, ExistTypeClassInfoModes),
-	list__condense([UnivTypeClassInfoModes, ExistTypeClassInfoModes,
-		UnivTypeInfoModes, ExistTypeInfoModes], ExtraArgModes),
+	list__condense([UnivTypeInfoModes, ExistTypeInfoModes,
+		UnivTypeClassInfoModes, ExistTypeClassInfoModes],
+		ExtraArgModes),
 		
 	%
 	% Add the locations of the typeinfos
Index: tests/hard_coded/typeclasses/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/typeclasses/Mmakefile,v
retrieving revision 1.30
diff -u -u -r1.30 Mmakefile
--- tests/hard_coded/typeclasses/Mmakefile	2000/07/06 06:25:24	1.30
+++ tests/hard_coded/typeclasses/Mmakefile	2000/08/24 05:55:35
@@ -39,6 +39,7 @@
 	superclass_call \
 	test_default_func_mode \
 	typeclass_exist_method \
+	typeclass_exist_method_2 \
 	typeclass_test_5 \
 	typeclass_test_6 \
 	type_spec \
@@ -61,7 +62,12 @@
 MCFLAGS-unqualified_method = --intermodule-optimization
 MCFLAGS-unqualified_method2 = --intermodule-optimization
 MCFLAGS-unqualified_method3 = --intermodule-optimization
-MCFLAGS-instance_unconstrained_tvar = --no-user-guided-type-specialisation
+
+# XXX Type specialization does not yet work for these test cases.
+NO_TYPE_SPEC_FLAGS = --no-user-guided-type-specialisation \
+				--no-type-specialisation
+MCFLAGS-instance_unconstrained_tvar = $(NO_TYPE_SPEC_FLAGS)
+MCFLAGS-typeclass_exist_method_2 = $(NO_TYPE_SPEC_FLAGS)
 
 #-----------------------------------------------------------------------------#
 
Index: tests/hard_coded/typeclasses/typeclass_exist_method_2.m
===================================================================
RCS file: typeclass_exist_method_2.m
diff -N typeclass_exist_method_2.m
--- /dev/null	Thu Aug 24 15:54:25 2000
+++ typeclass_exist_method_2.m	Thu Aug 24 15:22:59 2000
@@ -0,0 +1,29 @@
+% The compiler of 24/8/2000 added the modes for the type_info and
+% typeclass_info arguments of p/2 in the wrong order, resulting
+% in a mode error.
+%
+:- module typeclass_exist_method_2.
+:- interface.
+
+:- import_module io.
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+main -->
+	{ p(1, U) },
+	write(U), nl.
+
+
+:- typeclass t(T) where [
+  	some [U] pred p(T::in, U::out) is det
+].
+
+:- instance t(int) where [
+	pred(p/2) is p_int
+].
+
+:- some [T] pred p_int(int::in, T::out) is det.
+
+p_int(_, "OK").
+
Index: tests/hard_coded/typeclasses/typeclass_exist_method_2.exp
===================================================================
RCS file: typeclass_exist_method_2.exp
diff -N typeclass_exist_method_2.exp
--- /dev/null	Thu Aug 24 15:54:25 2000
+++ typeclass_exist_method_2.exp	Thu Aug 24 09:00:18 2000
@@ -0,0 +1 @@
+"OK"
--------------------------------------------------------------------------
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