[m-rev.] diff: enable tests/invalid/typeclass_test_8

Julien Fischer juliensf at cs.mu.OZ.AU
Thu Oct 20 15:49:20 AEST 2005


Estimated hours taken: 0.5
Branches: main

compiler/post_typecheck.m:
	Put `'s around the typeclass constraints when warning
	about unsatisfied typeclass constraints.

	Use unexpected/2 in place of error/1.

tests/invalid/Mmakefile:
	Enable invalid/typeclass_test_8 since we now pass that test.

Julien.

Index: compiler/post_typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/post_typecheck.m,v
retrieving revision 1.82
diff -u -r1.82 post_typecheck.m
--- compiler/post_typecheck.m	19 Oct 2005 05:39:01 -0000	1.82
+++ compiler/post_typecheck.m	20 Oct 2005 05:34:42 -0000
@@ -46,6 +46,8 @@
 :- import_module std_util.
 :- import_module term.

+%-----------------------------------------------------------------------------%
+
     % finish_preds(PredIds, ReportTypeErrors, NumErrors, FoundTypeError,
     %   !Module):
     %
@@ -343,11 +345,11 @@
         !IO),

     prog_out__write_context(Context, !IO),
-    io__write_string("  ", !IO),
+    io__write_string("  `", !IO),
     AppendVarnums = no,
-    io__write_list(Constraints, ", ",
+    io__write_list(Constraints, "', `",
         mercury_output_constraint(TVarSet, AppendVarnums), !IO),
-    io__write_string(".\n", !IO).
+    io__write_string("'.\n", !IO).

     % Report a warning: uninstantiated type parameter.
     %
@@ -491,7 +493,8 @@
                 ( list__split_list(HalfLength, Types0, Types1, _) ->
                     Types = Types1
                 ;
-                    error("finish_aditi_builtin: aditi_modify")
+                    unexpected(this_file,
+                        "finish_aditi_builtin: aditi_modify")
                 )
             )
     ),
@@ -572,7 +575,7 @@
             typecheck__resolve_pred_overloading(ModuleInfo, Markers, ArgTypes,
                 TVarSet, SymName0, SymName, PredId)
         ;
-            error("resolve_aditi_builtin_overloading")
+            unexpected(this_file, "resolve_aditi_builtin_overloading")
         )
     ;
         PredId = PredId0,
@@ -749,7 +752,7 @@
     ( Clauses = [clause(_ProcIds, Goal0, _Lang, _Context)] ->
         assertion__normalise_goal(Goal0, Goal)
     ;
-        error("promise_ex__goal: not an promise")
+        unexpected(this_file, "promise_ex__goal: not an promise")
     ).

 %-----------------------------------------------------------------------------%
@@ -1282,7 +1285,8 @@
         ( type_list_subsumes([FieldArgType], [FieldType], FieldSubst) ->
             apply_rec_subst_to_type_list(FieldSubst, ArgTypes0, ArgTypes)
         ;
-            error("translate_get_function: type_list_subsumes failed")
+            unexpected(this_file,
+                "translate_get_function: type_list_subsumes failed")
         )
     ;
         ExistQVars = [],
@@ -1358,7 +1362,8 @@
             remove_new_prefix(ConsName, ConsName0),
             ConsId = cons(ConsName, ConsArity)
         ;
-            error("translate_set_function: invalid cons_id")
+            unexpected(this_file,
+                "translate_set_function: invalid cons_id")
         )
     ),

@@ -1402,7 +1407,8 @@
     ( type_to_ctor_and_args(TermType, _, TypeArgs) ->
         map__from_corresponding_lists(TypeParams, TypeArgs, TSubst)
     ;
-        error("get_cons_id_arg_types_adding_existq_tvars: " ++
+        unexpected(this_file,
+            "get_cons_id_arg_types_adding_existq_tvars: " ++
             "type_to_ctor_and_args failed")

     ),
@@ -1420,7 +1426,7 @@
         At = At0,
         After = After0
     ;
-        error("split_list_at_index")
+        unexpected(this_file, "split_list_at_index")
     ).

 %-----------------------------------------------------------------------------%
@@ -1436,7 +1442,8 @@
     ( type_to_ctor_and_args(TermType, TermTypeCtor0, _) ->
         TermTypeCtor = TermTypeCtor0
     ;
-        error("get_constructor_containing_field: " ++
+        unexpected(this_file,
+            "get_constructor_containing_field: " ++
             "type_to_ctor_and_args failed")
     ),
     module_info_get_type_table(ModuleInfo, Types),
@@ -1446,14 +1453,14 @@
         get_constructor_containing_field_2(Ctors, FieldName, ConsId,
             FieldNumber)
     ;
-        error("get_constructor_containing_field: not du type")
+        unexpected(this_file, "get_constructor_containing_field: not du type")
     ).

 :- pred get_constructor_containing_field_2(list(constructor)::in,
     ctor_field_name::in, cons_id::out, int::out) is det.

 get_constructor_containing_field_2([], _, _, _) :-
-    error("get_constructor_containing_field: can't find field").
+    unexpected(this_file, "get_constructor_containing_field: can't find field").
 get_constructor_containing_field_2([Ctor | Ctors], FieldName,
         ConsId, FieldNumber) :-
     Ctor = ctor(_, _, SymName, CtorArgs),
@@ -1594,5 +1601,11 @@
     ).

 %-----------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "post_typecheck.m".
+
+%-----------------------------------------------------------------------------%
 :- end_module post_typecheck.
 %-----------------------------------------------------------------------------%
Index: tests/invalid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mmakefile,v
retrieving revision 1.181
diff -u -r1.181 Mmakefile
--- tests/invalid/Mmakefile	20 Oct 2005 04:46:03 -0000	1.181
+++ tests/invalid/Mmakefile	20 Oct 2005 05:35:17 -0000
@@ -174,6 +174,7 @@
 	typeclass_test_4 \
 	typeclass_test_5 \
 	typeclass_test_7 \
+	typeclass_test_8 \
 	typeclass_test_9 \
 	type_inf_loop \
 	type_loop \
@@ -226,8 +227,6 @@
 #		when doing dynamic linking, or when the library
 #		was built with `--split-c-files')
 #	parent.undeclared_child (just not yet implemented)
-#	typeclass_test_8 (minor formatting error in the output --
-#			the type class name should be in quotes)
 #	typeclass_mode_{2,3,4} (compiler calls error/1)
 #	ho_default_func_4 (due to a bug in the mode-checker ---
 #			see XXX comment in inst_match:inst_matches_final_3)

--------------------------------------------------------------------------
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