[m-dev.] for review: improve typeclass error message

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 3 14:10:58 AEDT 2000


On 03-Nov-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> 
> This looks good Fergus, but we should put a test case in the tests.
> (Feel free to put that one on a to-do list somewhere).

Done.  I'll commit this with the rest of the change.

tests/invalid/Mmakefile:
tests/invalid/method_impl.m:
tests/invalid/method_impl.exp:
	A regression test.

cvs diff: Diffing .
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.76
diff -u -d -u -r1.76 Mmakefile
--- Mmakefile	2000/10/13 13:56:16	1.76
+++ Mmakefile	2000/11/02 21:43:27
@@ -49,6 +49,7 @@
 	inst_list_dup.m \
 	io_in_ite_cond.m \
 	lambda_syntax_error.m \
+	method_impl.m \
 	missing_det_decls.m \
 	missing_interface_import.m \
 	modes_erroneous.m \
Index: method_impl.exp
===================================================================
RCS file: method_impl.exp
diff -N method_impl.exp
--- /dev/null	Thu Mar 30 14:06:13 2000
+++ method_impl.exp	Fri Nov  3 08:43:10 2000
@@ -0,0 +1,7 @@
+method_impl.m:016: In clause for type class method implementation:
+method_impl.m:016:   in argument 2 of predicate `foo_m1/2':
+method_impl.m:016:   type error: variable `HeadVar__2' has type `int',
+method_impl.m:016:   expected type was `string'.
+method_impl.m:019: In clause for type class method implementation:
+method_impl.m:019:   error: undefined predicate `bar_m1/2'.
+For more information, try recompiling with `-E'.
Index: method_impl.m
===================================================================
RCS file: method_impl.m
diff -N method_impl.m
--- /dev/null	Thu Mar 30 14:06:13 2000
+++ method_impl.m	Fri Nov  3 08:42:05 2000
@@ -0,0 +1,37 @@
+:- module method_impl.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io__state::di, io__state::uo) is det.
+
+:- typeclass c(T) where [
+	pred m1(T::in, int::out) is det
+].
+
+:- type foo ---> foo.
+:- type bar ---> bar.
+
+:- instance c(foo) where [
+	pred(m1/2) is foo_m1
+].
+:- instance c(bar) where [
+	pred(m1/2) is bar_m1
+].
+
+:- pred foo_m1(foo::in, string::out) is det.
+
+:- pred foo_m2(foo::in, int::in) is det.
+
+:- implementation.
+
+main -->
+	[].
+
+:- pragma c_header_code("int foo_counter = 0;").
+
+foo_m1(_, "forty two").
+
+foo_m2(_, _).
+
+
cvs diff: Diffing purity
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- 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