[m-rev.] diff: another fix for type qualification

Simon Taylor stayl at cs.mu.OZ.AU
Tue Jan 8 17:46:08 AEDT 2002


This is a temporary work-around for the problem Zoltan
reported at yesterday's meeting.

Simon.


Estimated hours taken: 0.5
Branches: main

compiler/intermod.m:
	Don't write clauses for predicates containing explicit
	type qualifications to `.opt' files. hlds_out__write_clause
	does not write explict type qualifications, which causes
	spurious type errors when the clauses from the `.opt' files
	are typechecked.

tests/hard_coded/Mmakefile:
tests/hard_coded/intermod_type_qual*:
	Test case.


Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.109
diff -u -u -r1.109 intermod.m
--- compiler/intermod.m	6 Nov 2001 15:20:44 -0000	1.109
+++ compiler/intermod.m	8 Jan 2002 06:00:31 -0000
@@ -237,13 +237,22 @@
 	{ map__lookup(PredTable0, PredId, PredInfo0) },
 	{ module_info_type_spec_info(ModuleInfo0, TypeSpecInfo) },
 	{ TypeSpecInfo = type_spec_info(_, TypeSpecForcePreds, _, _) },
+	{ pred_info_clauses_info(PredInfo0, ClausesInfo0) },
 	(
+		%
+		% XXX hlds_out__write_clause needs to be changed to
+		% output explicit type qualifications to avoid type
+		% ambiguity errors in clauses written to `.opt' files.
+		%
+		{ clauses_info_explicit_vartypes(ClausesInfo0,
+			ExplicitVarTypes) },
+		{ map__is_empty(ExplicitVarTypes) },
+
 		{ intermod__should_be_processed(ProcessLocalPreds, PredId,
 			PredInfo0, TypeSpecForcePreds, InlineThreshold,
 			HigherOrderSizeLimit, Deforestation, ModuleInfo0) }
 	->
 		=(IntermodInfo0),
-		{ pred_info_clauses_info(PredInfo0, ClausesInfo0) },
 		{ pred_info_typevarset(PredInfo0, TVarSet) },
 		{ clauses_info_vartypes(ClausesInfo0, VarTypes) },
 		{ clauses_info_clauses(ClausesInfo0, Clauses0) },
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.139
diff -u -u -r1.139 Mmakefile
--- tests/hard_coded/Mmakefile	7 Jan 2002 07:48:18 -0000	1.139
+++ tests/hard_coded/Mmakefile	7 Jan 2002 13:37:42 -0000
@@ -78,6 +78,7 @@
 	integer_test \
 	intermod_c_code \
 	intermod_multimode_main \
+	intermod_type_qual \
 	join_list \
 	merge_and_remove_dups \
 	minint_bug \
@@ -234,6 +235,8 @@
 MCFLAGS-impure_foreign	=	--optimize-duplicate-calls
 MCFLAGS-intermod_c_code =	--intermodule-optimization
 MCFLAGS-intermod_c_code2 =	--intermodule-optimization
+MCFLAGS-intermod_type_qual =	--intermodule-optimization
+MCFLAGS-intermod_type_qual2 =	--intermodule-optimization
 MCFLAGS-intermod_multimode =	--intermodule-optimization
 MCFLAGS-intermod_multimode_main = --intermodule-optimization
 MCFLAGS-nondet_copy_out =	--no-inlining --nondet-copy-out
Index: tests/hard_coded/intermod_type_qual.exp
===================================================================
RCS file: tests/hard_coded/intermod_type_qual.exp
diff -N tests/hard_coded/intermod_type_qual.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/intermod_type_qual.exp	7 Jan 2002 13:41:27 -0000
@@ -0,0 +1 @@
+1
Index: tests/hard_coded/intermod_type_qual.m
===================================================================
RCS file: tests/hard_coded/intermod_type_qual.m
diff -N tests/hard_coded/intermod_type_qual.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/intermod_type_qual.m	7 Jan 2002 13:41:04 -0000
@@ -0,0 +1,14 @@
+:- module intermod_type_qual.
+
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- import_module list, intermod_type_qual2.
+
+main --> p([1]).
+
Index: tests/hard_coded/intermod_type_qual2.m
===================================================================
RCS file: tests/hard_coded/intermod_type_qual2.m
diff -N tests/hard_coded/intermod_type_qual2.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/intermod_type_qual2.m	7 Jan 2002 13:41:04 -0000
@@ -0,0 +1,14 @@
+:- module intermod_type_qual2.
+
+:- interface.
+
+:- import_module list, io.
+
+:- pred p(list(T)::in, io__state::di, io__state::uo) is det.
+
+:- implementation.
+
+:- pragma inline(p/3).
+p(L) -->
+	io__write(list__length(L) `with_type` int),
+	io__nl.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list