[m-rev.] for review: better error messages for overloaded types

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Aug 8 14:30:21 AEST 2001


On 03-Aug-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Otherwise that looks fine.  Please post a relative diff.

Here it is, together with the diff of the Log files.

Zoltan.

--- /home/zs/mer/ws8/Log	Mon Aug  6 12:53:16 2001
+++ /home/zs/mer/ws9/Log	Wed Aug  8 14:30:26 2001
@@ -1,6 +1,9 @@
+When printing messages about errors involving overloaded types, print each
+type only once.
+
 compiler/typecheck.m:
-	When printing messages about errors involving overloaded types,
-	print each type only once.
+	Detect and eliminate duplicate type names in error messages about
+	overloaded types.
 
 	When a variable has more than one type, print each type on a line of
 	its own, to make the output easier to read. (Since type names currently
@@ -47,3 +50,6 @@
 
 tests/invalid/Mmakefile:
 	Enable the new test.
+
+NEWS:
+	Announce the changes in the library.

diff -u compiler/mercury_to_mercury.m compiler/mercury_to_mercury.m
--- compiler/mercury_to_mercury.m
+++ compiler/mercury_to_mercury.m
@@ -31,7 +31,7 @@
 % constant factor. If we ever want to use these functions to create long
 % strings (longer than a few lines), then we should use a typeclass
 % instance implementation that represents the entity being converted to string
-% as a list of strings that must be conceatenated together at the end using
+% as a list of strings that must be concatenated together at the end using
 % string__append_list (probably after being un-reversed, so that you can
 % represent appending to the string by consing onto the front of the list).
 % The complexity of an implementation like that can be linear in the size
@@ -3473,6 +3473,8 @@
 	).
 
 %-----------------------------------------------------------------------------%
+
+% This is the typeclass mentioned in the long comment at the top of the module.
 
 :- typeclass output(U) where [
 	pred add_string(string::in, U::di, U::uo) is det,
diff -u compiler/typecheck.m compiler/typecheck.m
--- compiler/typecheck.m
+++ compiler/typecheck.m
@@ -5388,7 +5388,7 @@
 write_types_list(_Context, []) --> [].
 write_types_list(Context, [Type | Types]) -->
 	prog_out__write_context(Context),
-	io__write_string("   "),
+	io__write_string("    "),
 	io__write_string(Type),
 	( { Types = [] } ->
 		io__write_string("\n")
diff -u library/string.m library/string.m
--- library/string.m
+++ library/string.m
@@ -30,6 +30,8 @@
 	% An empty string has length zero.
 
 :- func string__append(string, string) = string.
+:- mode string__append(in, in) = uo is det.
+
 :- pred string__append(string, string, string).
 :- mode string__append(in, in, in) is semidet.	% implied
 :- mode string__append(in, out, in) is semidet.
@@ -44,6 +46,7 @@
 % :- mode string__append(out, in, in) is semidet.
 
 :- func string ++ string = string.
+:- mode in ++ in = uo is det.
 %	S1 ++ S2 = S :- string__append(S1, S2, S).
 %
 %	Nicer syntax.
diff -u overloading.err_exp overloading.err_exp
--- overloading.err_exp
+++ overloading.err_exp
@@ -11,19 +11,19 @@
 overloading.m:050:   argument has type `'<any>'',
 overloading.m:050:   variable `Counter1' has type `(counter:counter)',
 overloading.m:050:   variable `StartMap0' has overloaded type {
-overloading.m:050:    (pred (tree234:tree234(V_V_1, V_V_2))),
-overloading.m:050:    (tree234:tree234(K, V))
-overloading.m:050:    },
+overloading.m:050:     (pred (tree234:tree234(V_V_1, V_V_2))),
+overloading.m:050:     (tree234:tree234(K, V))
+overloading.m:050:   },
 overloading.m:050:   variable `EndMap0' has overloaded type {
-overloading.m:050:    (pred (tree234:tree234((overloading:interval_id), (overloading:anchor)))),
-overloading.m:050:    (tree234:tree234((overloading:interval_id), (overloading:anchor)))
-overloading.m:050:    },
+overloading.m:050:     (pred (tree234:tree234((overloading:interval_id), (overloading:anchor)))),
+overloading.m:050:     (tree234:tree234((overloading:interval_id), (overloading:anchor)))
+overloading.m:050:   },
 overloading.m:050:   variable `VarsMap0' has overloaded type {
-overloading.m:050:    (pred (tree234:tree234((overloading:interval_id), (set:set((term:var((term:generic)))))))),
-overloading.m:050:    (tree234:tree234((overloading:interval_id), (set:set((term:var((term:generic)))))))
-overloading.m:050:    },
+overloading.m:050:     (pred (tree234:tree234((overloading:interval_id), (set:set((term:var((term:generic)))))))),
+overloading.m:050:     (tree234:tree234((overloading:interval_id), (set:set((term:var((term:generic)))))))
+overloading.m:050:   },
 overloading.m:050:   variable `SuccMap0' has overloaded type {
-overloading.m:050:    (pred (tree234:tree234(V_V_1, V_V_2))),
-overloading.m:050:    (tree234:tree234(K, V))
-overloading.m:050:    }.
+overloading.m:050:     (pred (tree234:tree234(V_V_1, V_V_2))),
+overloading.m:050:     (tree234:tree234(K, V))
+overloading.m:050:   }.
 For more information, try recompiling with `-E'.
only in patch2:
--- NEWS	2001/06/27 05:03:57	1.213
+++ NEWS	2001/08/06 07:27:17
@@ -42,6 +42,11 @@
 
 * We've added a predicate version of `set__fold'.
 
+* We've added some functions to the term_io module to return printable
+  representations of term components as strings.
+
+* We've made the outputs of the string concatenation primitives unique.
+
 Changes to the Mercury implementation:
 * We've fixed a long-standing bug in the handling of module imports.
   Previously, if `module1' imported `module2' which imported `module3' in
--------------------------------------------------------------------------
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