diff: bug fix for empty typeclass decls
David Glen JEFFERY
dgj at cs.mu.OZ.AU
Thu Jan 22 15:14:18 AEDT 1998
Hi,
Could you please review this, Fergus?
Estimated hours taken: 1
Bug fix. When there are no methods for a class, the maybe(list(pred_proc_id))
field of the hlds_instance_defn was left as no, rather than yes([]), so
base_typeclass_info.m bombed out when trying to generate the pointers to the
typeclass methods.
compiler/base_typeclass_info.m:
Explicitly check for typeclasses with no methods, and set the
mybe(list(pred_proc_id)) field to yes([]).
Index: compiler//check_typeclass.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/check_typeclass.m,v
retrieving revision 1.2
diff -u -r1.2 check_typeclass.m
--- check_typeclass.m 1998/01/13 09:57:16 1.2
+++ check_typeclass.m 1998/01/22 04:06:34
@@ -92,8 +92,21 @@
Errors0, Errors):-
% check conformance of the instance interface
- list__foldl2(check_instance_pred(Vars, ClassInterface, ModuleInfo),
- PredIds, InstanceDefn0, InstanceDefn1, Errors0, Errors1),
+ (
+ PredIds \= []
+ ->
+ list__foldl2(check_instance_pred(Vars, ClassInterface,
+ ModuleInfo), PredIds, InstanceDefn0, InstanceDefn1,
+ Errors0, Errors1)
+ ;
+ % there are no methods for this class
+ InstanceDefn0 = hlds_instance_defn(A, B, C, D,
+ _MaybeInstancePredProcs, F, G),
+ InstanceDefn1 = hlds_instance_defn(A, B, C, D,
+ yes([]), F, G),
+ Errors1 = Errors0
+ ),
+
% check that the superclass constraints are satisfied for the
% types in this instance declaration
love and cuddles,
dgj
--
David Jeffery (dgj at cs.mu.oz.au) | Marge: Did you just call everyone "chicken"?
MEngSc 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