[m-dev.] diff: fix bug in type overloading warning

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Apr 19 17:26:06 AEST 2000


Estimated hours taken: 0.5

compiler/typecheck.m:
	Fix a bug: rejj's changes to the error messages had
	broken the formatting of the "highly ambiguous overloading"
	warning.

tests/warnings/Mmakefile:
tests/warnings/ambiguous_overloading.m:
tests/warnings/ambiguous_overloading.exp:
	Regression test.

Workspace: /home/pgrad/fjh/ws/hg
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.274
diff -u -d -r1.274 typecheck.m
--- compiler/typecheck.m	2000/04/14 08:38:26	1.274
+++ compiler/typecheck.m	2000/04/17 06:21:04
@@ -4517,18 +4517,18 @@
 report_warning_too_much_overloading(TypeCheckInfo) -->
 	{ typecheck_info_get_context(TypeCheckInfo, Context) },
 	{ make_pred_id_preamble(TypeCheckInfo, Preamble) },
-	{ SmallWarning = [ Preamble,
-				"warning: highly ambiguous overloading." ] },
+	{ SmallWarning = [ fixed(Preamble),
+			words("warning: highly ambiguous overloading.") ] },
 	globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
 	( { VerboseErrors = yes } ->
-		{ VerboseWarning = [ "This may cause type-checking to be very",
-					"slow. It may also make your code",
-					"difficult to understand." ] },
-		{ list__append(SmallWarning, VerboseWarning, Warning0) }
+		{ VerboseWarning = [
+			words("This may cause type-checking to be very"),
+			words("slow. It may also make your code"),
+			words("difficult to understand.") ] },
+		{ list__append(SmallWarning, VerboseWarning, Warning) }
 	;
-		{ Warning0 = SmallWarning }
+		{ Warning = SmallWarning }
 	),
-	{ error_util__list_to_pieces(Warning0, Warning) },
 	error_util__report_warning(Context, 0, Warning).
 
 %-----------------------------------------------------------------------------%
Index: tests/warnings/ambiguous_overloading.exp
===================================================================
RCS file: ambiguous_overloading.exp
diff -N ambiguous_overloading.exp
--- /dev/null	Thu Mar 30 14:06:13 2000
+++ ambiguous_overloading.exp	Wed Apr 19 14:10:58 2000
@@ -0,0 +1,2 @@
+ambiguous_overloading.m:015: In clause for predicate `ambiguous_overloading:ambig_overload/1':
+ambiguous_overloading.m:015:   warning: highly ambiguous overloading.
Index: tests/warnings/ambiguous_overloading.m
===================================================================
RCS file: ambiguous_overloading.m
diff -N ambiguous_overloading.m
--- /dev/null	Thu Mar 30 14:06:13 2000
+++ ambiguous_overloading.m	Wed Apr 19 14:11:12 2000
@@ -0,0 +1,17 @@
+% Test the warning for ambiguous overloading.
+:- module ambiguous_overloading.
+
+:- interface.
+:- import_module list.
+
+:- type foo ---> f ; g.
+:- type bar ---> f ; h.
+
+:- pred ambig_overload(list(foo)::out) is det.
+
+:- implementation.
+
+ambig_overload(L) :-
+	A = f, B = f, C = f, D = f, E = f, F = f, G = f,
+	L = [A, B, C, D, E, F, G].
+
Index: tests/warnings/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/warnings/Mmakefile,v
retrieving revision 1.12
diff -u -d -r1.12 Mmakefile
--- tests/warnings/Mmakefile	2000/04/05 06:11:37	1.12
+++ tests/warnings/Mmakefile	2000/04/19 04:09:38
@@ -10,6 +10,7 @@
 	arg_order_rearrangment
 
 ERRORCHECK_PROGS= \
+	ambiguous_overloading \
 	det_infer_warning \
 	double_underscore \
 	duplicate_call \
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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