[m-dev.] diff: fix a typeclass bug

David Glen JEFFERY dgj at cs.mu.OZ.AU
Wed Jul 29 16:24:18 AEST 1998


On 29-Jul-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> DJ has already given this an "over-the-shoulder" review ;-)
> 
> Estimated hours taken: 1
> 
> compiler/check_typeclass.m:
> 	Fix a bug: when generating the goal for the introduced predicate
> 	(function) for each function method in an instance declarations,
> 	it was not setting the goal_info correctly.

And here's the test case:


Estimated hours taken: 0.1


tests/valid/typeclasses/func_method.m:
	Add a test case for a function as a typeclass method. The non-locals
	were not being set correctly, which caused a software error in this
	case.
tests/valid/typeclasses/Mmakefile:
	Turn this test on.

cvs diff: Diffing .
Index: Mmakefile
===================================================================
RCS file: /home/staff/zs/imp/tests/valid/Mmakefile,v
retrieving revision 1.20
diff -u -t -r1.20 Mmakefile
--- Mmakefile	1998/07/12 18:15:16	1.20
+++ Mmakefile	1998/07/29 06:21:55
@@ -33,6 +33,7 @@
         fail_ite.m \
         followcode_det_problem.m \
         func_int_bug_main.m \
+        func_method \
         headvar_not_found.m \
         higher_order.m \
         higher_order2.m \

===================================================================

%-----------------------------------------------------------------------------%
:- module func_method.
:- interface.

:- type pair(A, B) ---> pair(A, B).

:- typeclass c(A) where [
	func op(pair(A, B)) = pair(A, B),
	mode op(in) = out is det
].

:- instance c(int) where [
	func(op/1) is op_int
].

:- implementation.

:- func op_int(pair(int, T)) = pair(int, T).
:- mode op_int(in) = out is det.
op_int(X) = X.

%-----------------------------------------------------------------------------%





love and cuddles,
dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) |  Marge: Did you just call everyone "chicken"?
PhD student,                    |  Homer: Noooo.  I swear on this Bible!
Department of Computer Science  |  Marge: That's not a Bible; that's a book of
University of Melbourne         |         carpet samples!
Australia                       |  Homer: Ooooh... Fuzzy.



More information about the developers mailing list