for review: make type class error message more accurate

David Glen JEFFERY dgj at cs.mu.OZ.AU
Tue Dec 1 16:09:58 AEDT 1998


Hi Tyse,

This addresses your bug report from last week. What do you think?
---------------------------------------------------------------------------

Estimated hours taken: 1

compiler/check_typeclass.m:
	Add an indication of whether or not the type class method for which
	we are reporting an error is a predicate or a function.

tests/invalid/typeclass_test_3.err_exp:
tests/invalid/typeclass_test_4.err_exp:
tests/invalid/typeclass_test_5.err_exp:
	Updated to reflect the new error message format.

cvs diff: Diffing .
Index: check_typeclass.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/check_typeclass.m,v
retrieving revision 1.18
diff -u -t -r1.18 check_typeclass.m
--- check_typeclass.m	1998/11/20 04:07:04	1.18
+++ check_typeclass.m	1998/12/01 04:25:52
@@ -310,7 +310,16 @@
                 ClassId = class_id(ClassName, _ClassArity),
                 prog_out__sym_name_to_string(MethodName, MethodNameString),
                 prog_out__sym_name_to_string(ClassName, ClassNameString),
-                string__int_to_string(PredArity, PredArityString),
+                (
+                        PredOrFunc = predicate,
+                        PredOrFuncString = "predicate",
+                        RealPredArity = PredArity
+                ;
+                        PredOrFunc = function,
+                        PredOrFuncString = "function",
+                        RealPredArity = PredArity - 1
+                ),
+                string__int_to_string(RealPredArity, PredArityString),
                 mercury_type_list_to_string(InstanceVarSet, InstanceTypes,
                         InstanceTypesString),
                 string__append_list([
@@ -319,7 +328,9 @@
                         "(",
                         InstanceTypesString,
                         ")': ",
-                        "multiple implementations of type class method `",
+                        "multiple implementations of type class ",
+                        PredOrFuncString,
+                        " method `",
                         MethodNameString,
                         "/",
                         PredArityString,
@@ -348,7 +359,16 @@
                 ClassId = class_id(ClassName, _ClassArity),
                 prog_out__sym_name_to_string(MethodName, MethodNameString),
                 prog_out__sym_name_to_string(ClassName, ClassNameString),
-                string__int_to_string(PredArity, PredArityString),
+                (
+                        PredOrFunc = predicate,
+                        PredOrFuncString = "predicate",
+                        RealPredArity = PredArity
+                ;
+                        PredOrFunc = function,
+                        PredOrFuncString = "function",
+                        RealPredArity = PredArity - 1
+                ),
+                string__int_to_string(RealPredArity, PredArityString),
                 mercury_type_list_to_string(InstanceVarSet, InstanceTypes,
                         InstanceTypesString),
                 string__append_list([
@@ -357,7 +377,9 @@
                         "(",
                         InstanceTypesString,
                         ")': ",
-                        "no implementation for type class method `",
+                        "no implementation for type class ",
+                        PredOrFuncString,
+                        " method `",
                         MethodNameString,
                         "/",
                         PredArityString,
cvs diff: Diffing notes

cvs diff: Diffing .
Index: typeclass_test_3.err_exp
===================================================================
RCS file: /home/staff/zs/imp/tests/invalid/typeclass_test_3.err_exp,v
retrieving revision 1.7
diff -u -t -r1.7 typeclass_test_3.err_exp
--- typeclass_test_3.err_exp	1998/10/29 09:25:44	1.7
+++ typeclass_test_3.err_exp	1998/12/01 05:04:30
@@ -1,5 +1,5 @@
 typeclass_test_3.m:014: In instance declaration for
 typeclass_test_3.m:014:   `typeclass_test_3:numbered_type(int)': no
-typeclass_test_3.m:014:   implementation for type class method
-typeclass_test_3.m:014:   `typeclass_test_3:type_num/2'.
+typeclass_test_3.m:014:   implementation for type class function method
+typeclass_test_3.m:014:   `typeclass_test_3:type_num/1'.
 For more information, try recompiling with `-E'.
Index: typeclass_test_4.err_exp
===================================================================
RCS file: /home/staff/zs/imp/tests/invalid/typeclass_test_4.err_exp,v
retrieving revision 1.5
diff -u -t -r1.5 typeclass_test_4.err_exp
--- typeclass_test_4.err_exp	1998/10/29 09:25:44	1.5
+++ typeclass_test_4.err_exp	1998/12/01 05:04:59
@@ -1,5 +1,5 @@
 typeclass_test_4.m:014: In instance declaration for
 typeclass_test_4.m:014:   `typeclass_test_4:numbered_type(int)': no
-typeclass_test_4.m:014:   implementation for type class method
-typeclass_test_4.m:014:   `typeclass_test_4:type_num/2'.
+typeclass_test_4.m:014:   implementation for type class function method
+typeclass_test_4.m:014:   `typeclass_test_4:type_num/1'.
 For more information, try recompiling with `-E'.
Index: typeclass_test_5.err_exp
===================================================================
RCS file: /home/staff/zs/imp/tests/invalid/typeclass_test_5.err_exp,v
retrieving revision 1.3
diff -u -t -r1.3 typeclass_test_5.err_exp
--- typeclass_test_5.err_exp	1998/10/29 09:25:44	1.3
+++ typeclass_test_5.err_exp	1998/12/01 05:05:21
@@ -1,6 +1,6 @@
 typeclass_test_5.m:015: In instance declaration for `typeclass_test_5:c2(int)':
-typeclass_test_5.m:015:   multiple implementations of type class method
-typeclass_test_5.m:015:   `typeclass_test_5:p/1'.
+typeclass_test_5.m:015:   multiple implementations of type class predicate
+typeclass_test_5.m:015:   method `typeclass_test_5:p/1'.
 typeclass_test_5.m:016: First definition appears here.
 typeclass_test_5.m:017: Subsequent definition appears here.
 typeclass_test_5.m:015: In instance declaration for `typeclass_test_5:c2(int)':
---------------------------------------------------------------------------


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!
Dept. of Comp. Sci. & Soft. Eng.|  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