[m-rev.] for review: module qualification of equality preds

Simon Taylor stayl at cs.mu.OZ.AU
Mon May 19 13:38:17 AEST 2003


Estimated hours taken: 4
Branches: main, release

The compiler was not module qualifying the `where equality is ...'
part of type declarations in interface files. This could cause the
compiler to use the wrong predicate in importing modules if the
user-defined equality predicate was not exported.

To avoid this problem we now require user-defined equality or
comparison predicates for a type to be defined in the same module
as the type. This is the only simple way to module qualify the
unification predicates in interface files without running
typechecking.

compiler/prog_io.m:
compiler/prog_io_pragma.m:
	Require user-defined equality or comparison predicates for a
	type to be defined in the same module as the type.

compiler/typecheck.m:
compiler/post_typecheck.m:
compiler/hlds_pred.m:
compiler/make_hlds.m:
compiler/*.m:
	Calls in the compiler generated unification predicates are
	now guaranteed to be fully qualified, so don't attempt
	to search for more qualified predicates.

	Add a new pred_marker 'calls_are_fully_qualifed' to
	identify predicates whose bodies contain only fully
	qualified calls, rather than testing the import_status.

tests/invalid/Mmakefile:
tests/invalid/exported_unify.m:
tests/invalid/exported_unify2.m:
tests/invalid/exported_unify2.err_exp:
	Test case.

Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.307
diff -u -u -r1.307 hlds_out.m
--- compiler/hlds_out.m	14 May 2003 04:05:39 -0000	1.307
+++ compiler/hlds_out.m	18 May 2003 04:49:47 -0000
@@ -1024,6 +1024,7 @@
 hlds_out__marker_name(psn, "psn").
 hlds_out__marker_name(supp_magic, "supp_magic").
 hlds_out__marker_name(context, "context").
+hlds_out__marker_name(calls_are_fully_qualified, "calls_are_fully_qualified").
 hlds_out__marker_name(not_accessible_by_unqualifed_name,
 		"not_accessible_by_unqualifed_name").
 hlds_out__marker_name(not_accessible_by_partially_qualified_names,
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.123
diff -u -u -r1.123 hlds_pred.m
--- compiler/hlds_pred.m	28 Apr 2003 11:56:48 -0000	1.123
+++ compiler/hlds_pred.m	18 May 2003 03:21:16 -0000
@@ -373,7 +373,7 @@
 	% always fully qualified. For calls occurring in `.opt' files
 	% this will return `is_fully_qualified', otherwise
 	% `may_be_partially_qualified'.
-:- func calls_are_fully_qualified(import_status) = is_fully_qualified.
+:- func calls_are_fully_qualified(pred_markers) = is_fully_qualified.
 
 	% Predicates can be marked with various boolean flags, called
 	% "markers".
@@ -508,6 +508,12 @@
 				% If the compiler cannot guarantee termination
 				% then it must give an error message.
 
+	;	calls_are_fully_qualified
+				% All calls in this predicate are
+				% fully qualified. This occurs for
+				% predicates read from `.opt' files
+				% and compiler-generated predicates.
+
 	;	not_accessible_by_unqualifed_name
 				% This predicate is not accessible by its
 				% unqualified name.
@@ -969,8 +975,8 @@
 status_defined_in_this_module(exported_to_submodules,	yes).
 status_defined_in_this_module(local,			yes).
 
-calls_are_fully_qualified(Status) =
-	( Status = opt_imported ->
+calls_are_fully_qualified(Markers) =
+	( check_marker(Markers, calls_are_fully_qualified) ->
 	  is_fully_qualified
 	; may_be_partially_qualified
 	).
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.139
diff -u -u -r1.139 intermod.m
--- compiler/intermod.m	8 May 2003 03:39:54 -0000	1.139
+++ compiler/intermod.m	18 May 2003 04:55:27 -0000
@@ -922,7 +922,8 @@
 	;
 		InstanceMethodDefn0 = name(InstanceMethodName0),
 		PredOrFunc = predicate,
-		typecheck__resolve_pred_overloading(ModuleInfo, local,
+		init_markers(Markers),
+		typecheck__resolve_pred_overloading(ModuleInfo, Markers,
 			MethodCallArgTypes, MethodCallTVarSet,
 			InstanceMethodName0, InstanceMethodName, PredId),
 		PredIds = [PredId | PredIds0],
@@ -1123,7 +1124,9 @@
 	map__lookup(SpecialPreds, SpecialId - TypeCtor, UnifyPredId),
 	module_info_pred_info(ModuleInfo, UnifyPredId, UnifyPredInfo),
 	pred_info_arg_types(UnifyPredInfo, TVarSet, _, ArgTypes),
-	typecheck__resolve_pred_overloading(ModuleInfo, local, ArgTypes,
+	init_markers(Markers0),
+	add_marker(Markers0, calls_are_fully_qualified, Markers),
+	typecheck__resolve_pred_overloading(ModuleInfo, Markers, ArgTypes,
 		TVarSet, Pred0, Pred, UserEqPredId),
 	intermod__add_proc(UserEqPredId, _, Info0, Info).
 
@@ -1837,6 +1840,7 @@
 intermod__should_output_marker(generate_inline, _) :-
 	% This marker should only occur after the magic sets transformation.
 	error("intermod__should_output_marker: generate_inline").
+intermod__should_output_marker(calls_are_fully_qualified, no).
 intermod__should_output_marker(not_accessible_by_unqualifed_name, no).
 intermod__should_output_marker(not_accessible_by_partially_qualified_names, no).
 
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.439
diff -u -u -r1.439 make_hlds.m
--- compiler/make_hlds.m	8 May 2003 03:39:54 -0000	1.439
+++ compiler/make_hlds.m	18 May 2003 04:51:14 -0000
@@ -1310,7 +1310,8 @@
 		Clauses = clauses_info(ArgVarSet, VarTypes0, TVarNameMap,
 			VarTypes0, Args, [Clause], TI_VarMap, TCI_VarMap,
 			HasForeignClauses),
-		pred_info_get_markers(PredInfo0, Markers),
+		pred_info_get_markers(PredInfo0, Markers0),
+		add_marker(Markers0, calls_are_fully_qualified, Markers),
 		map__init(Proofs),
 
 		( pred_info_is_imported(PredInfo0) ->
@@ -3837,7 +3838,10 @@
 	),
 	unify_proc__generate_clause_info(SpecialPredId, Type, TypeBody,
 		Context, Module1, ClausesInfo),
-	pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo),
+	pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo2),
+	pred_info_get_markers(PredInfo2, Markers2),
+	add_marker(Markers2, calls_are_fully_qualified, Markers),
+	pred_info_set_markers(PredInfo2, Markers, PredInfo),
 	map__det_update(Preds0, PredId, PredInfo, Preds),
 	module_info_set_preds(Module1, Preds, Module).
 
@@ -4274,7 +4278,11 @@
 	% opt_imported preds are initially tagged as imported and are
 	% tagged as opt_imported only if/when we see a clause for them
 	{ Status = opt_imported ->
-		pred_info_set_import_status(PredInfo0, opt_imported, PredInfo1)
+		pred_info_set_import_status(PredInfo0,
+			opt_imported, PredInfo0a),
+		pred_info_get_markers(PredInfo0a, Markers0),
+		add_marker(Markers0, calls_are_fully_qualified, Markers1),
+		pred_info_set_markers(PredInfo0a, Markers1, PredInfo1)
 	;
 		PredInfo1 = PredInfo0
 	},
@@ -4375,8 +4383,8 @@
 		%
 		pred_info_all_procids(PredInfo6, ProcIds),
 		( ProcIds = [] ->
-			pred_info_get_markers(PredInfo6, Markers0),
-			add_marker(Markers0, infer_modes, Markers),
+			pred_info_get_markers(PredInfo6, Markers6),
+			add_marker(Markers6, infer_modes, Markers),
 			pred_info_set_markers(PredInfo6, Markers, PredInfo)
 		;
 			PredInfo = PredInfo6
Index: compiler/post_typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/post_typecheck.m,v
retrieving revision 1.50
diff -u -u -r1.50 post_typecheck.m
--- compiler/post_typecheck.m	28 Mar 2003 06:55:12 -0000	1.50
+++ compiler/post_typecheck.m	18 May 2003 04:48:34 -0000
@@ -467,11 +467,11 @@
 		% have the specified name and arity
 		% 
 		pred_info_typevarset(CallerPredInfo, TVarSet),
-		pred_info_import_status(CallerPredInfo, Status),
+		pred_info_get_markers(CallerPredInfo, Markers),
 		pred_info_clauses_info(CallerPredInfo, ClausesInfo),
 		clauses_info_vartypes(ClausesInfo, VarTypes),
 		map__apply_to_list(Args0, VarTypes, ArgTypes),
-		typecheck__resolve_pred_overloading(ModuleInfo, Status,
+		typecheck__resolve_pred_overloading(ModuleInfo, Markers,
 			ArgTypes, TVarSet, PredName0, PredName, PredId)
         ;
 		PredId = PredId0,
@@ -638,9 +638,10 @@
 			EvalMethod \= normal
 		->
 			call(AdjustArgTypes, ArgTypes0, ArgTypes),
-			pred_info_import_status(CallerPredInfo, Status),
-			typecheck__resolve_pred_overloading(ModuleInfo, Status,
-				ArgTypes, TVarSet, SymName0, SymName, PredId)
+			pred_info_get_markers(CallerPredInfo, Markers),
+			typecheck__resolve_pred_overloading(ModuleInfo,
+				Markers, ArgTypes, TVarSet,
+				SymName0, SymName, PredId)
 		;
 			error(
 			"post_typecheck__resolve_aditi_builtin_overloading")
@@ -1246,10 +1247,10 @@
 		%
 		\+ pred_info_is_field_access_function(ModuleInfo, PredInfo0),
 
-		pred_info_import_status(PredInfo0, Status),
+		pred_info_get_markers(PredInfo0, Markers),
 		module_info_get_predicate_table(ModuleInfo, PredTable),
 		predicate_table_search_func_sym_arity(PredTable,
-			calls_are_fully_qualified(Status),
+			calls_are_fully_qualified(Markers),
 			PredName, Arity, PredIds),
 
 		% Check if any of the candidate functions have
@@ -1300,8 +1301,8 @@
 		map__apply_to_list(ArgVars0, VarTypes0, ArgTypes0),
 		AllArgTypes = ArgTypes0 ++ HOArgTypes,
 		pred_info_typevarset(PredInfo0, TVarSet),
-		pred_info_import_status(PredInfo0, Status),
-		get_pred_id(calls_are_fully_qualified(Status), Name,
+		pred_info_get_markers(PredInfo0, Markers),
+		get_pred_id(calls_are_fully_qualified(Markers), Name,
 			PredOrFunc, TVarSet, AllArgTypes, ModuleInfo, PredId)
 	->
 		get_proc_id(ModuleInfo, PredId, ProcId),
Index: compiler/prog_io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_io.m,v
retrieving revision 1.219
diff -u -u -r1.219 prog_io.m
--- compiler/prog_io.m	15 Mar 2003 03:09:07 -0000	1.219
+++ compiler/prog_io.m	17 May 2003 16:40:52 -0000
@@ -185,7 +185,8 @@
 :- pred parse_type_defn_head(module_name, term, term, maybe_functor).
 :- mode parse_type_defn_head(in, in, in, out) is det.
 
-	% get_maybe_equality_compare_preds(Body0, Body, MaybeEqualPred):
+	% get_maybe_equality_compare_preds(ModuleName,
+	%		Body0, Body, MaybeEqualPred):
 	%	Checks if `Body0' is a term of the form
 	%		`<body> where equality is <symname>'
 	%		`<body> where comparison is <symname>'
@@ -195,9 +196,9 @@
 	%	MaybeEqualPred.  If not, returns Body = Body0 
 	%	and `no' in MaybeEqualPred.
 
-:- pred get_maybe_equality_compare_preds(term, term,
+:- pred get_maybe_equality_compare_preds(module_name, term, term,
 		maybe1(maybe(unify_compare))).
-:- mode get_maybe_equality_compare_preds(in, out, out) is det.
+:- mode get_maybe_equality_compare_preds(in, in, out, out) is det.
 
 %-----------------------------------------------------------------------------%
 
@@ -1522,7 +1523,7 @@
 parse_type_decl_type(ModuleName, "--->", [H, B], Condition, R) :-
 	/* get_condition(...), */
 	Condition = true,
-	get_maybe_equality_compare_preds(B, Body, EqCompare),
+	get_maybe_equality_compare_preds(ModuleName, B, Body, EqCompare),
 	process_du_type(ModuleName, H, Body, EqCompare, R).
 
 parse_type_decl_type(ModuleName, "==", [H, B], Condition, R) :-
@@ -1645,7 +1646,7 @@
 
 %-----------------------------------------------------------------------------%
 
-get_maybe_equality_compare_preds(B, Body, MaybeEqComp) :-
+get_maybe_equality_compare_preds(ModuleName, B, Body, MaybeEqComp) :-
 	( 
 		B = term__functor(term__atom("where"), Args, _Context1),
 		Args = [Body1, EqCompTerm]
@@ -1655,14 +1656,16 @@
 			parse_equality_or_comparison_pred_term("equality",
 				EqCompTerm, PredName)
 		->
-			parse_symbol_name(PredName, MaybeEqComp0),
+			parse_implicitly_qualified_symbol_name(ModuleName,
+				PredName, MaybeEqComp0),
 			process_maybe1(make_equality, MaybeEqComp0,
 				MaybeEqComp)
 		;
 			parse_equality_or_comparison_pred_term("comparison",
 				EqCompTerm, PredName)
 		->
-			parse_symbol_name(PredName, MaybeEqComp0),
+			parse_implicitly_qualified_symbol_name(ModuleName,
+				PredName, MaybeEqComp0),
 			process_maybe1(make_comparison, MaybeEqComp0,
 				MaybeEqComp)
 		;
@@ -1673,9 +1676,10 @@
 			parse_equality_or_comparison_pred_term("comparison",
 				CompTerm, CompPredNameTerm)
 		->
-			parse_symbol_name(EqPredNameTerm, EqPredNameResult),
-			parse_symbol_name(CompPredNameTerm,
-				CompPredNameResult),
+			parse_implicitly_qualified_symbol_name(ModuleName,
+				EqPredNameTerm, EqPredNameResult),
+			parse_implicitly_qualified_symbol_name(ModuleName,
+				CompPredNameTerm, CompPredNameResult),
 			(
 				EqPredNameResult = ok(EqPredName),
 				CompPredNameResult = ok(CompPredName),
Index: compiler/prog_io_pragma.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
retrieving revision 1.57
diff -u -u -r1.57 prog_io_pragma.m
--- compiler/prog_io_pragma.m	15 Mar 2003 03:09:07 -0000	1.57
+++ compiler/prog_io_pragma.m	17 May 2003 12:15:16 -0000
@@ -37,7 +37,7 @@
 	(
 		% new syntax: `:- pragma foo(...).'
 		PragmaTerms = [SinglePragmaTerm0],
-		get_maybe_equality_compare_preds(SinglePragmaTerm0,
+		get_maybe_equality_compare_preds(ModuleName, SinglePragmaTerm0,
 				SinglePragmaTerm, UnifyCompareResult),
 		SinglePragmaTerm = term__functor(term__atom(PragmaType), 
 					PragmaArgs, _),
Index: compiler/purity.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/purity.m,v
retrieving revision 1.57
diff -u -u -r1.57 purity.m
--- compiler/purity.m	21 Mar 2003 05:52:07 -0000	1.57
+++ compiler/purity.m	18 May 2003 04:45:35 -0000
@@ -754,9 +754,9 @@
 		{ list__append(ArgTypes0, VarArgTypes, PredArgTypes) },
 		ModuleInfo =^ module_info,
 		CallerPredInfo =^ pred_info,
-		{ pred_info_import_status(CallerPredInfo, CallerStatus) },
+		{ pred_info_get_markers(CallerPredInfo, CallerMarkers) },
 		( 
-			{ get_pred_id(calls_are_fully_qualified(CallerStatus),
+			{ get_pred_id(calls_are_fully_qualified(CallerMarkers),
 				PName, PredOrFunc, TVarSet, PredArgTypes,
 				ModuleInfo, CalleePredId) }
 		->
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.336
diff -u -u -r1.336 typecheck.m
--- compiler/typecheck.m	28 Mar 2003 06:55:13 -0000	1.336
+++ compiler/typecheck.m	18 May 2003 04:47:22 -0000
@@ -127,7 +127,7 @@
 	% Abort if there is no matching pred.
 	% Abort if there are multiple matching preds.
 
-:- pred typecheck__resolve_pred_overloading(module_info, import_status,
+:- pred typecheck__resolve_pred_overloading(module_info, pred_markers,
 		list(type), tvarset, sym_name, sym_name, pred_id).
 :- mode typecheck__resolve_pred_overloading(in,
 		in, in, in, in, out, out) is det.
@@ -471,10 +471,11 @@
 		;
 			IsFieldAccessFunction = no
 		),
+		pred_info_get_markers(!.PredInfo, Markers),
 		typecheck_info_init(!.IOState, ModuleInfo, PredId,
 				IsFieldAccessFunction, TypeVarSet0, VarSet,
 				ExplicitVarTypes0, HeadTypeParams1,
-				Constraints, Status, TypeCheckInfo1),
+				Constraints, Status, Markers, TypeCheckInfo1),
 		typecheck_info_get_type_assign_set(TypeCheckInfo1,
 				OrigTypeAssignSet),
 		typecheck_clause_list(Clauses1, HeadVars, ArgTypes0, Clauses,
@@ -927,7 +928,10 @@
 		Clause = clause(ProcIds, Goal, mercury, Context),
 		clauses_info_set_clauses(ClausesInfo0, [Clause], ClausesInfo),
 		pred_info_update_goal_type(PredInfo0, clauses, PredInfo1),
-		pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo)
+		pred_info_set_clauses_info(PredInfo1, ClausesInfo, PredInfo2),
+		pred_info_get_markers(PredInfo2, Markers0),
+		add_marker(Markers0, calls_are_fully_qualified, Markers),
+		pred_info_set_markers(PredInfo2, Markers, PredInfo)
 	;
 		PredInfo = PredInfo0
 	).
@@ -1703,7 +1707,7 @@
 		CallId = PorF - SymName/Arity,
 		predicate_table_search_pf_sym_arity(PredicateTable,
 			calls_are_fully_qualified(
-				TypeCheckInfo1 ^ import_status),
+				TypeCheckInfo1 ^ pred_markers),
 			PorF, SymName, Arity, PredIdList)
 	->
 		% handle the case of a non-overloaded predicate specially
@@ -1806,7 +1810,7 @@
 	(
 		predicate_table_search_pf_sym(PredicateTable,
 			calls_are_fully_qualified(
-				TypeCheckInfo1 ^ import_status),
+				TypeCheckInfo1 ^ pred_markers),
 			PredOrFunc0, SymName, OtherIds),
 		predicate_table_get_preds(PredicateTable, Preds),
 		OtherIds \= []
@@ -1820,7 +1824,7 @@
 		),
 		predicate_table_search_pf_sym(PredicateTable,
 			calls_are_fully_qualified(
-				TypeCheckInfo1 ^ import_status),
+				TypeCheckInfo1 ^ pred_markers),
 			PredOrFunc, SymName, OtherIds),
 		OtherIds \= []
 	->
@@ -1895,12 +1899,13 @@
 	% module qualified, so they should not be considered
 	% when resolving overloading.
 
-typecheck__resolve_pred_overloading(ModuleInfo, Status, ArgTypes, TVarSet,
-		 PredName0, PredName, PredId) :-
+typecheck__resolve_pred_overloading(ModuleInfo, CallerMarkers,
+		ArgTypes, TVarSet, PredName0, PredName, PredId) :-
 	module_info_get_predicate_table(ModuleInfo, PredTable),
 	(
 		predicate_table_search_pred_sym(PredTable,
-			calls_are_fully_qualified(Status), PredName0, PredIds0)
+			calls_are_fully_qualified(CallerMarkers),
+			PredName0, PredIds0)
 	->
 		PredIds = PredIds0
 	;
@@ -3058,7 +3063,7 @@
 	(
 		predicate_table_search_sym(PredicateTable,
 			calls_are_fully_qualified(
-				TypeCheckInfo ^ import_status),
+				TypeCheckInfo ^ pred_markers),
 			SymName, PredIdList)
 	->
 		predicate_table_get_preds(PredicateTable, Preds),
@@ -3536,6 +3541,9 @@
 					% Import status of the pred
 					% being checked
 
+			pred_markers ::	pred_markers,
+					% Markers of the pred being checked
+
 			is_field_access_function :: bool,
 					% Is the pred we're checking
 					% a field access function?
@@ -3577,7 +3585,7 @@
 /*
 :- inst uniq_typecheck_info	=	bound_unique(
 					typecheck_info(
-						unique, ground,
+						unique, ground, ground,
 						ground, ground, ground, ground,
 						ground, ground, ground, ground,
 						ground, ground, ground
@@ -3596,7 +3604,7 @@
 /*
 :- inst typecheck_info_no_io	=	bound_unique(
 					typecheck_info(
-						dead, ground,
+						dead, ground, ground,
 						ground, ground, ground, ground,
 						ground, ground, ground, ground,
 						ground, ground, ground
@@ -3615,14 +3623,14 @@
 
 :- pred typecheck_info_init(io__state, module_info, pred_id, bool, tvarset,
 	prog_varset, map(prog_var, type), headtypes, class_constraints,
-	import_status, typecheck_info).
-:- mode typecheck_info_init(di, in, in, in, in, in, in, in, in, in,
+	import_status, pred_markers, typecheck_info).
+:- mode typecheck_info_init(di, in, in, in, in, in, in, in, in, in, in,
 	typecheck_info_uo)
 	is det.
 
 typecheck_info_init(IOState0, ModuleInfo, PredId, IsFieldAccessFunction,
 		TypeVarSet, VarSet, VarTypes, HeadTypeParams,
-		Constraints, Status, TypeCheckInfo) :-
+		Constraints, Status, Markers, TypeCheckInfo) :-
 	CallPredId = call(predicate - unqualified("") / 0),
 	term__context_init(Context),
 	map__init(TypeBindings),
@@ -3631,7 +3639,7 @@
 	WarnedAboutOverloading = no,
 	unsafe_promise_unique(IOState0, IOState),	% XXX
 	TypeCheckInfo = typecheck_info(
-		IOState, ModuleInfo, CallPredId, 0, PredId, Status,
+		IOState, ModuleInfo, CallPredId, 0, PredId, Status, Markers,
 		IsFieldAccessFunction, Context,
 		unify_context(explicit, []), VarSet, 
 		[type_assign(VarTypes, TypeVarSet, HeadTypeParams,
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.274
diff -u -u -r1.274 reference_manual.texi
--- doc/reference_manual.texi	13 Apr 2003 05:22:10 -0000	1.274
+++ doc/reference_manual.texi	19 May 2003 03:03:21 -0000
@@ -3466,6 +3466,9 @@
 The equality predicate must be ``pure'' (@pxref{Impurity}).
 
 @item
+The equality predicate must be defined in the same module as the type.
+
+ at item
 @var{equalitypred} should be an equivalence relation; that is, it must be
 symmetric, reflexive, and transitive.  However, the compiler is not required
 to check this at footnote{If @var{equalitypred} is not an equivalence relation,
@@ -3534,6 +3537,9 @@
 
 @item
 The comparison predicate must also be ``pure'' (@pxref{Impurity}).
+
+ at item
+The comparison predicate must be defined in the same module as the type.
 
 @item
 The relation
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.135
diff -u -u -r1.135 Mmakefile
--- tests/invalid/Mmakefile	17 Feb 2003 06:02:22 -0000	1.135
+++ tests/invalid/Mmakefile	19 May 2003 02:58:55 -0000
@@ -16,6 +16,7 @@
 	aditi_update_errors \
 	aditi_update_mode_errors \
 	duplicate_instance_2 \
+	exported_unify \
 	ho_default_func_2.sub \
 	import_in_parent \
 	imported_mode \
Index: tests/invalid/exported_unify.err_exp
===================================================================
RCS file: tests/invalid/exported_unify.err_exp
diff -N tests/invalid/exported_unify.err_exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/exported_unify.err_exp	19 May 2003 02:59:37 -0000
@@ -0,0 +1,3 @@
+exported_unify2.int:003: In clause for unification predicate for type (exported_unify2.foo):
+exported_unify2.int:003:   error: undefined predicate `exported_unify2.unify_foo/2'.
+For more information, try recompiling with `-E'.
Index: tests/invalid/exported_unify.m
===================================================================
RCS file: tests/invalid/exported_unify.m
diff -N tests/invalid/exported_unify.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/exported_unify.m	19 May 2003 02:58:24 -0000
@@ -0,0 +1,13 @@
+:- module exported_unify.
+
+:- interface.
+
+:- pred unify_foo(T::in, T::in) is semidet.
+
+:- implementation.
+
+:- import_module exported_unify2.
+
+unify_foo(A, A).
+
+
Index: tests/invalid/exported_unify2.m
===================================================================
RCS file: tests/invalid/exported_unify2.m
diff -N tests/invalid/exported_unify2.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/invalid/exported_unify2.m	19 May 2003 02:58:24 -0000
@@ -0,0 +1,14 @@
+:- module exported_unify2.
+
+:- interface.
+
+:- type foo ---> foo where equality is unify_foo.
+
+:- implementation.
+
+:- import_module std_util.
+
+:- pred unify_foo(foo::in, foo::in) is semidet.
+
+unify_foo(_, _) :- semidet_fail.
+
--------------------------------------------------------------------------
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