[m-dev.] diff: fix typeclass method determinism warnings

Simon Taylor stayl at cs.mu.OZ.AU
Sat Nov 4 23:44:06 AEDT 2000



Estimated hours taken: 0.25

compiler/det_report.m:
	Don't report "determinism declaration could be tighter"
	warnings for type-class method implementations -- they
	will usually be spurious.

tests/valid/Mmakefile:
tests/valid/typeclass_det_warning.m:
	Test case.


Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -u -r1.61 -r1.62
--- compiler/det_report.m	2000/10/13 13:55:19	1.61
+++ compiler/det_report.m	2000/11/04 12:40:01	1.62
@@ -162,7 +162,19 @@
 			globals__io_lookup_bool_option(
 				warn_det_decls_too_lax,
 				ShouldIssueWarning),
-			( { ShouldIssueWarning = yes } ->
+			{ pred_info_get_markers(PredInfo0, Markers) },
+			(
+				{ ShouldIssueWarning = yes },
+
+				% Don't report warnings for class method
+				% implementations -- the determinism in the
+				% `:- typeclass' declaration will be
+				% the loosest of all possible instances.
+				% This is similar to the reason we don't
+				% report warnings for lambda expressions.
+				{ \+ check_marker(Markers,
+					class_instance_method) }
+			->
 				{ Message = "  warning: determinism declaration could be tighter.\n" },
 				report_determinism_problem(PredId,
 					ProcId, ModuleInfo0, Message,
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -u -r1.77 -r1.78
--- tests/valid/Mmakefile	2000/10/27 06:16:08	1.77
+++ tests/valid/Mmakefile	2000/11/04 12:40:05	1.78
@@ -24,7 +24,8 @@
 	constraint_proof_bug.m \
 	func_method.m \
 	instance_superclass.m \
-	instance_unconstrained_tvar.m
+	instance_unconstrained_tvar.m \
+	typeclass_det_warning
 
 ADITI_SOURCES= \
 	aditi_error_bug.m \
@@ -257,6 +258,7 @@
 MCFLAGS-simplify_bug		= -O-1
 MCFLAGS-two_way_unif		= -O-1
 MCFLAGS-type_inf_ambig_test	= --infer-all
+MCFLAGS-typeclass_det_warning	= --halt-at-warn
 MCFLAGS-unify_typeinfo_bug	= -O3 --no-special-preds
 MCFLAGS-uniq_mode_inf_bug	= --infer-all
 MCFLAGS-vn_float		= -O5

tests/valid/typeclass_det_warning.m
===================================================================
% Check that the compiler doesn't give
% "determinism declaration could be tighter"
% warnings for type class method implementations.
% They will usually be spurious.
:- module typeclass_det_warning.

:- interface.

:- typeclass my_enum(T) where [
	func my_from_int(int) = T is semidet
].

:- instance my_enum(int).

:- implementation.

:- import_module std_util.

:- instance my_enum(int) where [
	func(my_from_int/1) is id
].

--------------------------------------------------------------------------
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