[m-dev.] diff: fix bug in user-guided type specialization

Simon Taylor stayl at cs.mu.OZ.AU
Fri Oct 27 17:43:30 AEDT 2000



Estimated hours taken: 1

compiler/make_hlds.m:
	Make `:- pragma type_spec' declarations which select a
	specific mode work when the mode selected is not the
	first.

tests/hard_coded/Mmakefile:
tests/hard_coded/type_spec_modes.m:
tests/hard_coded/type_spec_modes.exp:
	Test case.



Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.355
diff -u -u -r1.355 make_hlds.m
--- compiler/make_hlds.m	2000/10/27 06:16:02	1.355
+++ compiler/make_hlds.m	2000/10/27 06:16:58
@@ -1279,9 +1279,7 @@
 		->
 			{ map__lookup(Procs0, ProcId, ProcInfo) },
 			{ map__init(Procs1) },
-			{ hlds_pred__initial_proc_id(NewProcId) },
-			{ map__det_insert(Procs1, NewProcId,
-				ProcInfo, Procs) },
+			{ map__det_insert(Procs1, ProcId, ProcInfo, Procs) },
 			{ ProcIds = [ProcId] },
 			{ ModesOk = yes },
 			{ ModuleInfo = ModuleInfo0 }
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.95
diff -u -u -r1.95 Mmakefile
--- tests/hard_coded/Mmakefile	2000/10/27 05:01:16	1.95
+++ tests/hard_coded/Mmakefile	2000/10/27 05:20:58
@@ -109,6 +109,7 @@
 	type_qual \
 	type_to_term_bug \
 	tuple_test \
+	type_spec_modes \
 	user_defined_equality \
 	user_defined_equality2 \
 	write \
Index: tests/hard_coded/type_spec_modes.exp
===================================================================
RCS file: type_spec_modes.exp
diff -N type_spec_modes.exp
--- /dev/null	Fri Oct 27 17:40:06 2000
+++ type_spec_modes.exp	Fri Oct 27 16:26:59 2000
@@ -0,0 +1,3 @@
+yes
+yes
+yes
Index: tests/hard_coded/type_spec_modes.m
===================================================================
RCS file: type_spec_modes.m
diff -N type_spec_modes.m
--- /dev/null	Fri Oct 27 17:40:06 2000
+++ type_spec_modes.m	Fri Oct 27 17:39:11 2000
@@ -0,0 +1,43 @@
+:- module type_spec_modes.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module int, list.
+
+:- pred my_unify(T, T).
+:- mode my_unify(in, in) is semidet.
+:- mode my_unify(in, out) is det.
+:- mode my_unify(out, in) is det.
+:- pragma type_spec(my_unify(in, in), T = list(int)).
+:- pragma type_spec(my_unify(in, in), T = int).
+:- pragma type_spec(my_unify(in, out), T = int).
+:- pragma type_spec(my_unify(out, in), T = list(int)).
+
+:- pragma no_inline(my_unify/2).
+
+my_unify(X, X).
+
+main -->
+	( { my_unify(1, 1) } ->
+		io__write_string("yes\n")
+	;
+		io__write_string("no\n")
+	),
+	( { my_unify([1, 2, 3], [1, 2, 6]) } ->
+		io__write_string("no\n")
+	;
+		io__write_string("yes\n")
+	),
+	{ my_unify(X, [1, 2, 3]) },
+	( { X = [1, 2, 3] } ->
+		io__write_string("yes\n")
+	;
+		io__write_string("no\n")
+	).
+
--------------------------------------------------------------------------
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