[m-rev.] for post-commit review: error specifications

Zoltan Somogyi zs at csse.unimelb.edu.au
Thu Sep 7 15:50:00 AEST 2006


The main ideas of this diff have already been discussed and accepted, so
I will commit this and deal with any comments later.

Zoltan.

A big step towards cleaning up the way we handle errors. The main changes are 

- the provision, in error_util.m, of a mechanism for completely specifying
  everything to do with a single error in one data structure,

- the conversion of typecheck_errors.m from using io.write_string to
  using this new capability,

- the conversion of mode_errors.m and det_report.m from using
  write_error_pieces to using this new capability, and

- consistently using the quoting style `symname'/N instead of `symname/N'
  in error_util and hlds_error_util (previously, error_util used the former
  but hlds_error_util used the latter).

This diff sets up later diffs which will collect all error specifications
in a central place and print them all at once, in order.

compiler/error_util.m:
	The new type error_spec, which completely specifies an error.
	An error_spec may have multiple components with different contexts
	and may have parts which are printed only under certain conditions,
	e.g. a given option being set. Each error_spec has a severity
	and also records which phase found the error.

	The new predicate write_error_spec takes care of updates of the exit
	status for errors and (if --halt-at-warn is set) for warnings. It also
	takes care of setting the flag that calls for the reminder about -E
	at the end.

	This diff also makes it simpler to use the ability to print arbitrary
	output. It adds the ability to include integers in messages directly,
	and the ability to create blank lines. It renames some function symbols
	to avoid ambiguities.

	Move a predicate that only used by typecheck_errors.m to that file.

compiler/hlds_error_util.m:
	Switch to the `symname'/N quoting style for describing predicates and
	procedures.

compiler/prog_util.m:
	Switch to the `symname'/N quoting style for describing
	sym_name_and_arity.

compiler/hlds_module.m:
	Provide a predicate to increment the number of errors not by one,
	but by the number of errors printed by write_error_spec.

	Fix some documentation rot.

compiler/typecheck_errors.m:
	Use write_error_spec instead of io.write_strings to print error
	messages. In several cases, improve the formatting of the messages
	printed.

	Mark a number of places where we don't (yet) update the number of
	errors in the module_info correctly.

	Rename the checkpoint predicate to avoid potential ambiguity with
	similar predicates in e.g. mode_info.

compiler/typecheck_info.m:
	Group the code for writing stuff out together in one bunch. For each
	such predicate, create another that returns a list of format components
	instead of doing I/O directly.

compiler/typecheck.m:
	Move the code for writing inference messages here from
	typecheck_errors.m, since these messages aren't errors.

compiler/mode_errors.m:
compiler/det_report.m:
	Use write_error_spec instead of write_error_pieces. In the case of
	mode_errors.m, this means we now get correct the set of circumstances
	in which we set the flag that calls for the reminder about -E.

compiler/add_pragma.m:
compiler/add_type.m:
	Convert some code that used to use write_error_pieces to print error
	messages to use write_error_spec instead.

compiler/assertion.m:
compiler/hlds_pred.m:
compiler/post_typecheck.m:
	Assertion.m used to contain some code to check for assertions in the
	interface that mention predicates that are not exported. Move most
	of this code to post_typecheck.m (which is where this code used to be
	called from). One small part, which is a test for a particular property
	of import_statuses, is moved to hlds_pred.m to be with all the other
	similar tests of import_statuses.

compiler/prog_util.m:
	Change unqualify_name from a predicate to a function.

compiler/pred_table.m:
compiler/hlds_out.m:
	Avoid some ambiguities by adding a suffix to the names of some
	predicates.

compiler/*.m:
	Conform to the changes above.

library/list.m:
	Add a function that was previously present (with different names)
	in two compiler modules.

tests/hard_coded/allow_stubs.exp:
	Update the format of the expected exception.

tests/invalid/errors2.err_exp2:
	Remove this file. As far as I can tell, it was never the correct
	expected output on the main branch. (It originated on the alias branch
	way back in the mists of time.)

tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/warnings/*.exp:
	Update the format of the expected error messages.

tests/recompilation/*.err_exp.2:
	Update the format of the expected messages about what was modified.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/add_class.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_class.m,v
retrieving revision 1.19
diff -u -b -r1.19 add_class.m
--- compiler/add_class.m	20 Aug 2006 08:20:50 -0000	1.19
+++ compiler/add_class.m	2 Sep 2006 14:35:32 -0000
@@ -661,7 +661,7 @@
         words("Error: mode declaration for type class method"),
         sym_name_and_arity(Name / Arity),
         words("without corresponding"),
-        pred_or_func(PredOrFunc),
+        p_or_f(PredOrFunc),
         words("method declaration.")
     ],
     write_error_pieces(Context, 0, NoPredOrFuncMsg, !IO),
Index: compiler/add_clause.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_clause.m,v
retrieving revision 1.31
diff -u -b -r1.31 add_clause.m
--- compiler/add_clause.m	5 Sep 2006 06:21:23 -0000	1.31
+++ compiler/add_clause.m	5 Sep 2006 06:27:11 -0000
@@ -204,7 +204,7 @@
             CallId = simple_call_id(PredOrFunc, PredName, Arity),
             ErrorPieces0 = [
                 words("Error: clause for automatically generated"),
-                words("field access"), simple_call_id(CallId), suffix("."), nl
+                words("field access"), simple_call(CallId), suffix("."), nl
             ],
             globals.io_lookup_bool_option(verbose_errors, Verbose, !IO),
             (
Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.46
diff -u -b -r1.46 add_pragma.m
--- compiler/add_pragma.m	30 Aug 2006 04:45:58 -0000	1.46
+++ compiler/add_pragma.m	7 Sep 2006 00:43:51 -0000
@@ -62,12 +62,11 @@
     maybe(structure_reuse_domain)::in, prog_context::in,
     module_info::in, module_info::out, io::di, io::uo) is det.
 
-    % module_add_pragma_import.
+    % module_add_pragma_import:
     %
     % Handles `pragma import' declarations, by figuring out which predicate
     % the `pragma import' declaration applies to, and adding a clause
-    % for that predicate containing an appropriate HLDS `pragma_c_code'
-    % instruction.
+    % for that predicate containing an appropriate HLDS `foreign_proc' goal.
     %
     % NB. Any changes here might also require similar changes to the
     % handling of `pragma export' declarations, in export.m.
@@ -381,8 +380,11 @@
                     words("a declared determinism of"),
                     fixed(hlds_out.determinism_to_string(Det) ++ ".")
                 ],
-                write_error_pieces(Context, 0, Pieces, !IO),
-                module_info_incr_errors(!ModuleInfo)
+                Msg = simple_msg(Context, [always(Pieces)]),
+                Spec = error_spec(severity_error, phase_parse_tree_to_hlds,
+                    [Msg]),
+                write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+                module_info_incr_num_errors(NumErrors, !ModuleInfo)
             ;
                 % Emit a warning about using pragma foreign_export with
                 % a foreign language that is not supported.
@@ -393,7 +395,7 @@
                     ; Lang = lang_il
                     ; Lang = lang_managed_cplusplus
                     ),
-                    NotImplementedWarning = [
+                    Pieces = [
                         words("Warning:"),
                         fixed("`:- pragma foreign_export'"),
                         words("declarations are not yet implemented"),
@@ -401,15 +403,16 @@
                         words(foreign_language_string(Lang)),
                         suffix(".")
                     ],
-                    report_warning(Context, 0, NotImplementedWarning, !IO)
+                    Msg = simple_msg(Context, [always(Pieces)]),
+                    Spec = error_spec(severity_warning,
+                        phase_parse_tree_to_hlds, [Msg]),
+                    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO)
                 ;
                     Lang = lang_c
                 ),
-                %
-                % Only add the foreign export if the specified language
-                % matches one of the foreign languages available for this
-                % backend.
-                %
+
+                % Only add the foreign export if the specified language matches
+                % one of the foreign languages available for this backend.
                 io_get_backend_foreign_languages(ForeignLanguages, !IO),
                 (   
                     % XXX C# and Managed C++ exports currently cause an
@@ -487,12 +490,9 @@
         !IO) :-
     TypeCtor = type_ctor(TypeName, TypeArity),
     module_info_get_type_table(!.ModuleInfo, Types0),
-    TypeStr = describe_sym_name_and_arity(TypeName / TypeArity),
-    ErrorPieces1 = [
-        words("In"),
-        fixed("`pragma reserve_tag'"),
-        words("declaration for"),
-        fixed(TypeStr ++ ":")
+    ContextPieces = [
+        words("In"), fixed("`pragma reserve_tag'"), words("declaration for"),
+        sym_name_and_arity(TypeName / TypeArity), suffix(":"), nl
     ],
     ( map.search(Types0, TypeCtor, TypeDefn0) ->
         hlds_data.get_type_defn_body(TypeDefn0, TypeBody0),
@@ -507,43 +507,33 @@
                 )
             )
         ->
-            write_error_pieces(Context, 0, ErrorPieces1, !IO),
-            ErrorPieces2 = [
-                words("error: `reserve_tag' declaration must"),
-                words("have the same visibility as the"),
-                words("type definition.")
-            ],
-            write_error_pieces_not_first_line(Context, 0, ErrorPieces2, !IO),
-            io.set_exit_status(1, !IO),
-            module_info_incr_errors(!ModuleInfo)
-
+            MaybeSeverity = yes(severity_error),
+            ErrorPieces = [
+                words("error: `reserve_tag' declaration must have"),
+                words("the same visibility as the type definition.")
+            ]
         ;
             TypeBody0 = hlds_du_type(Body, _CtorTags0, _IsEnum0,
                 MaybeUserEqComp, ReservedTag0, IsForeign)
         ->
             (
                 ReservedTag0 = yes,
-                % make doubly sure that we don't get any
-                % spurious warnings with intermodule
-                % optimization...
+                % Make doubly sure that we don't get any spurious warnings
+                % with intermodule optimization...
                 TypeStatus \= status_opt_imported
             ->
-                write_error_pieces(Context, 0, ErrorPieces1, !IO),
-                ErrorPieces2 = [
-                    words("warning: multiple"),
-                    fixed("`pragma reserved_tag'"),
+                MaybeSeverity = yes(severity_warning),
+                ErrorPieces = [
+                    words("warning: multiple"), fixed("`pragma reserved_tag'"),
                     words("declarations for the same type.")
-                ],
-                write_error_pieces_not_first_line(Context, 0, ErrorPieces2,
-                    !IO)
+                ]
             ;
-                true
+                MaybeSeverity = no,
+                ErrorPieces = []
             ),
-            %
-            % We passed all the semantic checks.
-            % Mark the type has having a reserved tag,
-            % and recompute the constructor tags.
-            %
+
+            % We passed all the semantic checks. Mark the type has having
+            % a reserved tag, and recompute the constructor tags.
             ReservedTag = yes,
             module_info_get_globals(!.ModuleInfo, Globals),
             assign_constructor_tags(Body, MaybeUserEqComp, TypeCtor,
@@ -554,25 +544,33 @@
             map.set(Types0, TypeCtor, TypeDefn, Types),
             module_info_set_type_table(Types, !ModuleInfo)
         ;
-            write_error_pieces(Context, 0, ErrorPieces1, !IO),
-            ErrorPieces2 = [
-                words("error:"),
-                fixed(TypeStr),
-                words("is not a discriminated union type.")
-            ],
-            write_error_pieces_not_first_line(Context, 0, ErrorPieces2, !IO),
-            io.set_exit_status(1, !IO),
-            module_info_incr_errors(!ModuleInfo)
+            MaybeSeverity = yes(severity_error),
+            ErrorPieces = [
+                words("error:"), sym_name_and_arity(TypeName / TypeArity),
+                words("is not a discriminated union type."), nl
+            ]
         )
     ;
-        write_error_pieces(Context, 0, ErrorPieces1, !IO),
-        ErrorPieces2 = [
+        MaybeSeverity = yes(severity_error),
+        ErrorPieces = [
             words("error: undefined type"),
-            fixed(TypeStr ++ ".")
-        ],
-        write_error_pieces_not_first_line(Context, 0, ErrorPieces2, !IO),
-        io.set_exit_status(1, !IO),
-        module_info_incr_errors(!ModuleInfo)
+            sym_name_and_arity(TypeName / TypeArity), suffix("."), nl
+        ]
+    ),
+    (
+        ErrorPieces = []
+    ;
+        ErrorPieces = [_ | _],
+        (
+            MaybeSeverity = yes(Severity)
+        ;
+            MaybeSeverity = no,
+            unexpected(this_file, "add_pragma_reserve_tag: no severity")
+        ),
+        Msg = simple_msg(Context, [always(ContextPieces ++ ErrorPieces)]),
+        Spec = error_spec(Severity, phase_parse_tree_to_hlds, [Msg]),
+        write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+        module_info_incr_num_errors(NumErrors, !ModuleInfo)
     ).
 
 %-----------------------------------------------------------------------------%
@@ -595,10 +593,12 @@
             UnusedArgInfo),
         module_info_set_unused_arg_info(UnusedArgInfo, !ModuleInfo)
     ;
-        module_info_incr_errors(!ModuleInfo),
         Pieces = [words("Internal compiler error: "),
             words("unknown predicate in `pragma unused_args'.")],
-        write_error_pieces(Context, 0, Pieces, !IO)
+        Msg = simple_msg(Context, [always(Pieces)]),
+        Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
+        write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+        module_info_incr_num_errors(NumErrors, !ModuleInfo)
     ).
 
 %-----------------------------------------------------------------------------%
@@ -708,7 +708,7 @@
             predicate_table_search_sym_arity(Preds, is_fully_qualified,
                 SymName, Arity, PredIds)
         ),
-        PredIds \= []
+        PredIds = [_ | _]
     ->
         list.foldl3(add_pragma_type_spec_2(Pragma, Context), PredIds,
             !ModuleInfo, !QualInfo, !IO)
@@ -740,15 +740,13 @@
         globals.io_lookup_bool_option(smart_recompilation, Smart, !IO),
         (
             ModesOk = yes,
-            % Even if we aren't doing type specialization, we need
-            % to create the interface procedures for local
-            % predicates to check the type-class correctness of
-            % the requested specializations.
-            %
-            % If we're doing smart recompilation we need to record
-            % the pragmas even if we aren't doing type
-            % specialization to avoid problems with differing
-            % output for the recompilation tests in debugging
+            % Even if we aren't doing type specialization, we need to create
+            % the interface procedures for local predicates to check the
+            % type-class correctness of the requested specializations.
+            %
+            % If we're doing smart recompilation we need to record the pragmas
+            % even if we aren't doing type specialization to avoid problems
+            % with differing output for the recompilation tests in debugging
             % grades.
             %
             ( DoTypeSpec = yes
@@ -756,24 +754,21 @@
             ; Smart = yes
             )
         ->
-            %
-            % Build a clause to call the old predicate with the
-            % specified types to force the specialization.
-            % For imported predicates this forces the creation
-            % of the proper interface.
+            % Build a clause to call the old predicate with the specified types
+            % to force the specialization. For imported predicates this forces
+            % the creation of the proper interface.
             %
             PredOrFunc = pred_info_is_pred_or_func(PredInfo0),
             adjust_func_arity(PredOrFunc, Arity, PredArity),
             varset.init(ArgVarSet0),
             make_n_fresh_vars("HeadVar__", PredArity, Args,
                 ArgVarSet0, ArgVarSet),
-            % XXX We could use explicit type qualifications here
-            % for the argument types, but explicit type
-            % qualification doesn't work correctly with type
-            % inference due to a bug somewhere in typecheck.m
-            % -- the explicitly declared types are not kept in
-            % sync with the predicate's tvarset after the first
-            % pass of type checking.
+            % XXX We could use explicit type qualifications here for the
+            % argument types, but explicit type qualification doesn't work
+            % correctly with type inference due to a bug somewhere in
+            % typecheck.m -- the explicitly declared types are not kept in
+            % sync with the predicate's tvarset after the first pass of
+            % type checking.
             % map.from_corresponding_lists(Args, Types, VarTypes0)
             map.init(VarTypes0),
             goal_info_init(GoalInfo0),
@@ -781,13 +776,11 @@
             goal_info_set_nonlocals(NonLocals, GoalInfo0, GoalInfo1),
             goal_info_set_context(Context, GoalInfo1, GoalInfo),
 
-            %
-            % We don't record the called predicate as used -- it
-            % is only used if there is some other call. This call
-            % is only used to make higher_order.m generate
-            % the interface for the type specialized procedure, and
-            % will be removed by higher_order.m after that is done.
-            %
+            % We don't record the called predicate as used -- it is only used
+            % if there is some other call. This call is only used to make
+            % higher_order.m generate the interface for the type specialized
+            % procedure, and will be removed by higher_order.m after that
+            % is done.
             do_construct_pred_or_func_call(PredId, PredOrFunc,
                 SymName, Args, GoalInfo, Goal),
             Clause = clause(ProcIds, Goal, impl_lang_mercury, Context),
@@ -823,9 +816,7 @@
                 PredTable0, PredTable),
             module_info_set_predicate_table(PredTable, !ModuleInfo),
 
-            %
             % Record the type specialisation in the module_info.
-            %
             module_info_get_type_spec_info(!.ModuleInfo, TypeSpecInfo0),
             TypeSpecInfo0 = type_spec_info(ProcsToSpec0,
                 ForceVersions0, SpecMap0, PragmaMap0),
@@ -938,8 +929,8 @@
                 get_new_tvars(VarsToReplace, TVarSet0, CalledTVarSet, TVarSet,
                     NameVarIndex0, _, TVarRenaming0, TVarRenaming),
 
-                % Check that none of the existentially
-                % quantified variables were substituted.
+                % Check that none of the existentially quantified variables
+                % were substituted.
                 map.apply_to_list(VarsToSub, TVarRenaming, RenamedVarsToSub),
                 pred_info_get_exist_quant_tvars(PredInfo0, ExistQVars),
                 list.filter((pred(RenamedVar::in) is semidet :-
@@ -1086,7 +1077,7 @@
     PredOrFunc = pred_info_is_pred_or_func(PredInfo),
     SimpleCallId = simple_call_id(PredOrFunc, qualified(Module, Name), Arity),
     Pieces = [words("In `:- pragma type_spec' declaration for"),
-        simple_call_id(SimpleCallId), suffix(":"), nl].
+        simple_call(SimpleCallId), suffix(":"), nl].
 
 :- func report_variables(list(tvar), tvarset) = string.
 
@@ -1182,14 +1173,14 @@
                 module_info_incr_errors(!ModuleInfo),
                 Pieces = [words("Error: `:- pragma termination2_info'"),
                     words("declaration for undeclared mode of"),
-                    simple_call_id(simple_call_id(PredOrFunc, SymName, Arity)),
+                    simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                     suffix(".")],
                 write_error_pieces(Context, 0, Pieces, !IO)
             )
         ;
             module_info_incr_errors(!ModuleInfo),
             Pieces = [words("Error: ambiguous predicate name"),
-                simple_call_id(simple_call_id(PredOrFunc, SymName, Arity)),
+                simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                 words("in"), fixed("`pragma termination2_info'.")],
             write_error_pieces(Context, 0, Pieces, !IO)
         )
@@ -1236,14 +1227,14 @@
                 module_info_incr_errors(!ModuleInfo),
                 Pieces = [words("Error: `:- pragma structure_sharing'"),
                     words("declaration for undeclared mode of"),
-                    simple_call_id(simple_call_id(PredOrFunc, SymName, Arity)),
+                    simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                     suffix(".")],
                 write_error_pieces(Context, 0, Pieces, !IO)
             )
         ;
             module_info_incr_errors(!ModuleInfo),
             Pieces = [words("Error: ambiguous predicate name"),
-                simple_call_id(simple_call_id(PredOrFunc, SymName, Arity)),
+                simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                 words("in"), fixed("`pragma structure_sharing'.")],
             write_error_pieces(Context, 0, Pieces, !IO)
         )
@@ -1289,14 +1280,14 @@
                 module_info_incr_errors(!ModuleInfo),
                 Pieces = [words("Error: `:- pragma structure_reuse'"),
                     words("declaration for undeclared mode of"),
-                    simple_call_id(simple_call_id(PredOrFunc, SymName, Arity)),
+                    simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                     suffix(".")],
                 write_error_pieces(Context, 0, Pieces, !IO)
             )
         ;
             module_info_incr_errors(!ModuleInfo),
             Pieces = [words("Error: ambiguous predicate name"),
-                simple_call_id(simple_call_id(PredOrFunc, SymName, Arity)),
+                simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                 words("in"), fixed("`pragma structure_reuse'.")],
             write_error_pieces(Context, 0, Pieces, !IO)
         )
@@ -1347,14 +1338,14 @@
                 module_info_incr_errors(!ModuleInfo),
                 Pieces = [words("Error: `:- pragma termination_info'"),
                     words("declaration for undeclared mode of"),
-                    simple_call_id(simple_call_id(PredOrFunc, SymName, Arity)),
+                    simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                     suffix(".")],
                 write_error_pieces(Context, 0, Pieces, !IO)
             )
         ;
             module_info_incr_errors(!ModuleInfo),
             Pieces = [words("Error: ambiguous predicate name"),
-                simple_call_id(simple_call_id(PredOrFunc, SymName, Arity)),
+                simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
                 words("in"), fixed("`pragma termination_info'.")],
             write_error_pieces(Context, 0, Pieces, !IO)
         )
@@ -1411,13 +1402,13 @@
     ( pred_info_is_imported(PredInfo1) ->
         module_info_incr_errors(!ModuleInfo),
         Pieces = [words("Error: `:- pragma import' declaration for imported"),
-            simple_call_id(simple_call_id(PredOrFunc, PredName, Arity)),
+            simple_call(simple_call_id(PredOrFunc, PredName, Arity)),
             suffix(".")],
         write_error_pieces(Context, 0, Pieces, !IO)
     ; pred_info_clause_goal_type(PredInfo1) ->
         module_info_incr_errors(!ModuleInfo),
         Pieces = [words("Error: `:- pragma import' declaration for"),
-            simple_call_id(simple_call_id(PredOrFunc, PredName, Arity)),
+            simple_call(simple_call_id(PredOrFunc, PredName, Arity)),
             words("with preceding clauses.")],
         write_error_pieces(Context, 0, Pieces, !IO)
     ;
@@ -1439,7 +1430,7 @@
             module_info_incr_errors(!ModuleInfo),
             Pieces = [words("Error: `:- pragma import' declaration"),
                 words("for undeclared mode of"),
-                simple_call_id(simple_call_id(PredOrFunc, PredName, Arity)),
+                simple_call(simple_call_id(PredOrFunc, PredName, Arity)),
                 suffix(".")],
             write_error_pieces(Context, 0, Pieces, !IO)
         )
@@ -1589,7 +1580,7 @@
             Pieces = [words("Error: `:- pragma foreign_proc'"),
                 words("(or `pragma c_code')"),
                 words("declaration for imported"),
-                simple_call_id(simple_call_id(PredOrFunc, PredName, Arity)),
+                simple_call(simple_call_id(PredOrFunc, PredName, Arity)),
                 suffix(".")],
             write_error_pieces(Context, 0, Pieces, !IO)
         ;
@@ -1641,7 +1632,7 @@
                 module_info_incr_errors(!ModuleInfo),
                 Pieces = [words("Error: `:- pragma foreign_proc' declaration"),
                     words("for undeclared mode of"),
-                    simple_call_id(SimpleCallId), suffix(".")],
+                    simple_call(SimpleCallId), suffix(".")],
                 write_error_pieces(Context, 0, Pieces, !IO)
             )
         )
@@ -1791,7 +1782,7 @@
     ->
         TablePragmaStr = string.format("`:- pragma %s'", [s(EvalMethodStr)]),
         InlineWarning = [
-            words("Warning: "), simple_call_id(SimpleCallId),
+            words("Warning: "), simple_call(SimpleCallId),
             words("has a"), fixed(TablePragmaStr),
             words("declaration but also has a"),
             fixed("`:- pragma inline'"), words("declaration."), nl,
@@ -1809,7 +1800,7 @@
         Pieces1 = [words("Error: "),
             fixed("`:- pragma " ++ EvalMethodStr ++ "'"),
             words("declaration for imported"),
-            simple_call_id(SimpleCallId), suffix(".")],
+            simple_call(SimpleCallId), suffix(".")],
         write_error_pieces(Context, 0, Pieces1, !IO)
     ;
         % Do we have to make sure the tabled preds are stratified?
@@ -1842,7 +1833,7 @@
                 Pieces2 = [words("Error:"),
                     fixed("`:- pragma " ++ EvalMethodStr ++ "'"),
                     words("declaration for undeclared mode of"),
-                    simple_call_id(SimpleCallId), suffix(".")],
+                    simple_call(SimpleCallId), suffix(".")],
                 write_error_pieces(Context, 0, Pieces2, !IO)
             )
         ;
@@ -1852,7 +1843,7 @@
                 module_info_incr_errors(!ModuleInfo),
                 Pieces3 = [words("Error: "),
                     fixed("`:- pragma " ++ EvalMethodStr ++ "'"),
-                    words("declaration for"), simple_call_id(SimpleCallId),
+                    words("declaration for"), simple_call(SimpleCallId),
                     words("with no declared modes.")],
                 write_error_pieces(Context, 0, Pieces3, !IO)
             ;
@@ -1910,13 +1901,13 @@
         % this procedure.
         EvalMethodStr = eval_method_to_string(EvalMethod),
         ( OldEvalMethod = EvalMethod ->
-            Pieces = [words("Error:"), simple_call_id(SimpleCallId),
+            Pieces = [words("Error:"), simple_call(SimpleCallId),
                 words("has duplicate"), fixed(EvalMethodStr),
                 words("pragmas specified.")
             ]
         ;
             OldEvalMethodStr = eval_method_to_string(OldEvalMethod),
-            Pieces = [words("Error:"), simple_call_id(SimpleCallId),
+            Pieces = [words("Error:"), simple_call(SimpleCallId),
                 words("has both"), fixed(OldEvalMethodStr), words("and"),
                 fixed(EvalMethodStr), words("pragmas specified."),
                 words("Only one kind of tabling pragma may be applied to it.")
@@ -1932,7 +1923,7 @@
             EvalMethodStr = eval_method_to_string(EvalMethod),
             Pieces = [words("Error:"),
                 fixed("`pragma" ++ EvalMethodStr ++ "'"),
-                words("declaration for"), simple_call_id(SimpleCallId),
+                words("declaration for"), simple_call(SimpleCallId),
                 suffix(","), words("which has no declared modes.")
             ],
             module_info_incr_errors(!ModuleInfo),
@@ -1962,7 +1953,7 @@
                 EvalMethodStr = eval_method_to_string(EvalMethod),
                 Pieces = [words("Error in"),
                     fixed("`pragma " ++ EvalMethodStr ++ "'"),
-                    words("declaration for"), simple_call_id(SimpleCallId),
+                    words("declaration for"), simple_call(SimpleCallId),
                     suffix(":"), nl, fixed(ArgMsg), words(ErrorMsg)
                 ],
                 module_info_incr_errors(!ModuleInfo),
@@ -2164,10 +2155,10 @@
     globals.lookup_bool_option(Globals, highlevel_code, HighLevelCode),
     module_info_get_name(ModuleInfo, ModuleName),
     SimpleCallId = simple_call_id(PredOrFunc, PredSymName, Arity),
+    PredName = unqualify_name(PredSymName),
     (
         HighLevelCode = yes,
         MaybeModuleName = no,
-        unqualify_name(PredSymName, PredName),
         % We set CodeModel and NoReturnValue to dummy values because we cannot
         % do any better right now. The code in that outputs the mlds_proc_label
         % of an mlds_tabling_ref should use mlds_std_tabling_proc_label to
@@ -2181,7 +2172,6 @@
             mlds_tabling_data_name(MLDS_ProcLabel, tabling_info)
     ;
         HighLevelCode = no,
-        unqualify_name(PredSymName, PredName),
         proc_id_to_int(ProcId, ProcIdInt),
         ProcLabel = ordinary_proc_label(ModuleName, PredOrFunc, ModuleName,
             PredName, Arity, ProcIdInt),
@@ -2488,7 +2478,7 @@
         adjust_func_arity(PredOrFunc, OrigArity, Arity),
         SimpleCallId = simple_call_id(PredOrFunc, PredName, OrigArity),
         Pieces1 = [words("In `:- pragma foreign_proc' declaration for"),
-            simple_call_id(SimpleCallId), suffix(":"), nl],
+            simple_call(SimpleCallId), suffix(":"), nl],
         (
             MultipleArgs = [MultipleArg],
             Pieces2 = [words("error: variable `" ++
@@ -2533,10 +2523,10 @@
                 purity_name(Purity, PurityStr),
                 ErrorMsg = [
                     words("Error: foreign clause for"),
-                    pred_or_func(PredOrFunc), 
+                    p_or_f(PredOrFunc),
                     sym_name_and_arity(PredName / Arity),
                     words("has purity " ++ ForeignAttributePurityStr),
-                    words("but that"), pred_or_func(PredOrFunc),
+                    words("but that"), p_or_f(PredOrFunc),
                     words("has been declared " ++ PurityStr), suffix(".")
                 ],
                 write_error_pieces(Context, 0, ErrorMsg, !IO),
@@ -2607,7 +2597,6 @@
         set_user_annotated_sharing(FormalUserSharing, !Attributes)
     ).
     
-    
 :- func is_applicable_for_current_backend(backend,
     list(pragma_foreign_proc_extra_attribute)) = bool.
 
Index: compiler/add_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pred.m,v
retrieving revision 1.22
diff -u -b -r1.22 add_pred.m
--- compiler/add_pred.m	30 Aug 2006 04:45:58 -0000	1.22
+++ compiler/add_pred.m	2 Sep 2006 15:13:24 -0000
@@ -201,7 +201,7 @@
             )
         ;
             module_info_get_partial_qualifier_info(!.ModuleInfo, PQInfo),
-            predicate_table_insert(PredInfo0, NeedQual, PQInfo, PredId,
+            predicate_table_insert_qual(PredInfo0, NeedQual, PQInfo, PredId,
                 PredTable0, PredTable1),
             ( pred_info_is_builtin(PredInfo0) ->
                 add_builtin(PredId, Types, PredInfo0, PredInfo),
@@ -488,8 +488,8 @@
             is_fully_qualified, PredOrFunc, PredName, Arity, _)
     ->
         module_info_get_partial_qualifier_info(ModuleInfo, MQInfo),
-        predicate_table_insert(PredInfo, may_be_unqualified, MQInfo, PredId,
-            !PredicateTable)
+        predicate_table_insert_qual(PredInfo, may_be_unqualified, MQInfo,
+            PredId, !PredicateTable)
     ;
         unexpected(this_file, "preds_add_implicit")
     ).
@@ -501,8 +501,7 @@
 
 unspecified_det_for_local(Name, Arity, PredOrFunc, Context, !IO) :-
     Pieces = [words("Error: no determinism declaration for local"),
-        words(simple_call_id_to_string(PredOrFunc, Name, Arity)),
-        suffix(".")],
+        simple_call(simple_call_id(PredOrFunc, Name, Arity)), suffix(".")],
     write_error_pieces(Context, 0, Pieces, !IO),
     record_warning(!IO),
     globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
@@ -524,10 +523,8 @@
 
 unspecified_det_for_method(Name, Arity, PredOrFunc, Context, !IO) :-
     Pieces = [words("Error: no determinism declaration"),
-        words("for type class method"),
-        pred_or_func(PredOrFunc),
-        sym_name_and_arity(Name / Arity),
-        suffix(".")],
+        words("for type class method"), p_or_f(PredOrFunc),
+        sym_name_and_arity(Name / Arity), suffix(".")],
     write_error_pieces(Context, 0, Pieces, !IO),
     io.set_exit_status(1, !IO).
 
@@ -536,9 +533,7 @@
 
 unspecified_det_for_exported(Name, Arity, PredOrFunc, Context, !IO) :-
     Pieces = [words("Error: no determinism declaration for exported"),
-        pred_or_func(PredOrFunc),
-        sym_name_and_arity(Name / Arity),
-        suffix(".")],
+        p_or_f(PredOrFunc), sym_name_and_arity(Name / Arity), suffix(".")],
     write_error_pieces(Context, 0, Pieces, !IO),
     io.set_exit_status(1, !IO).
 
Index: compiler/add_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_type.m,v
retrieving revision 1.18
diff -u -b -r1.18 add_type.m
--- compiler/add_type.m	20 Aug 2006 08:20:51 -0000	1.18
+++ compiler/add_type.m	7 Sep 2006 00:43:59 -0000
@@ -85,7 +85,6 @@
 module_add_type_defn(TVarSet, Name, Args, TypeDefn, _Cond, Context,
         item_status(Status0, NeedQual), !ModuleInfo, !IO) :-
     globals.io_get_globals(Globals, !IO),
-    globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
     list.length(Args, Arity),
     TypeCtor = type_ctor(Name, Arity),
     convert_type_defn(TypeDefn, TypeCtor, Globals, Body0),
@@ -108,8 +107,8 @@
     ),
     (
         % Discriminated unions whose definition consists of a single
-        % zero-arity constructor are not allowed to have user-defined
-        % equality or comparison.
+        % zero-arity constructor are dummy types. Dummy types are not allowed
+        % to have user-defined equality or comparison.
         %
         TypeDefn = parse_tree_du_type(Ctors, MaybeUserUC),
         Ctors = [Constructor],
@@ -118,27 +117,24 @@
         % Only report errors for types defined in this module.
         status_defined_in_this_module(Status0) = yes
     ->
-        DummyTypeError = [
+        DummyMainPieces = [
             words("Error: the type"),
             sym_name_and_arity(Name / Arity),
             words("is not allowed to have user-defined equality"),
             words("or comparison.")
         ],
-        (
-            VerboseErrors = yes,
-            VerboseDummyTypeError = [
+        DummyVerbosePieces = [
                 words("Discriminated unions whose body consists of a single"),
                 words("zero-arity constructor cannot have user-defined"),
                 words("equality or comparison.")
             ],
-            CompleteDummyTypeError = DummyTypeError ++ VerboseDummyTypeError
-        ;
-            VerboseErrors = no,
-            globals.io_set_extra_error_info(yes, !IO),
-            CompleteDummyTypeError = DummyTypeError
-        ),
-        write_error_pieces(Context, 0, CompleteDummyTypeError, !IO),
-        io.set_exit_status(1, !IO)
+        DummyMsg = simple_msg(Context,
+            [always(DummyMainPieces), verbose_only(DummyVerbosePieces)]),
+        DummySpec = error_spec(severity_error, phase_parse_tree_to_hlds,
+            [DummyMsg]),
+        write_error_spec(DummySpec, 0, _DummyNumWarnings, 0, DummyNumErrors,
+            !IO),
+        module_info_incr_num_errors(DummyNumErrors, !ModuleInfo)
     ;
         true
     ),
@@ -154,13 +150,16 @@
         ( is_solver_type_is_inconsistent(OldBody, Body) ->
             % The existing definition has an is_solver_type annotation
             % which is different to the current definition.
-            module_info_incr_errors(!ModuleInfo),
-            Pieces0 = [words("In definition of type"),
-                fixed(describe_sym_name_and_arity(Name / Arity) ++ ":"), nl,
-                words("error: all definitions of a type must"),
-                words("have consistent `solver'"),
-                words("annotations")],
-            write_error_pieces(Context, 0, Pieces0, !IO),
+            SolverPieces = [words("In definition of type"),
+                sym_name_and_arity(Name / Arity), suffix(":"), nl,
+                words("error: all definitions of a type must have"),
+                words("consistent `solver' annotations")],
+            SolverMsg = simple_msg(Context, [always(SolverPieces)]),
+            SolverSpec = error_spec(severity_error, phase_parse_tree_to_hlds,
+                [SolverMsg]),
+            write_error_spec(SolverSpec, 0, _SolverNumWarnings,
+                0, SolverNumErrors, !IO),
+            module_info_incr_num_errors(SolverNumErrors, !ModuleInfo),
             MaybeOldDefn = no
         ;
             hlds_data.set_type_defn_body(OldBody, OldDefn0, OldDefn),
@@ -181,14 +180,16 @@
         MaybeOldDefn = no,
         Body = hlds_foreign_type(_)
     ->
-        TypeStr = describe_sym_name_and_arity(Name / Arity),
-        ErrorPieces = [
-            words("Error: type "),
-            fixed(TypeStr),
+        ForeignDeclPieces = [
+            words("Error: type "), sym_name_and_arity(Name / Arity),
             words("defined as foreign_type without being declared.")
         ],
-        write_error_pieces(Context, 0, ErrorPieces, !IO),
-        module_info_incr_errors(!ModuleInfo)
+        ForeignDeclMsg = simple_msg(Context, [always(ForeignDeclPieces)]),
+        ForeignDeclSpec = error_spec(severity_error, phase_parse_tree_to_hlds,
+            [ForeignDeclMsg]),
+        write_error_spec(ForeignDeclSpec, 0, _ForeignDeclNumWarnings,
+            0, ForeignDeclNumErrors, !IO),
+        module_info_incr_num_errors(ForeignDeclNumErrors, !ModuleInfo)
     ;
         MaybeOldDefn = yes(OldDefn1),
         Body = hlds_foreign_type(_),
@@ -198,14 +199,17 @@
         status_is_exported_to_non_submodules(OldStatus1) = no,
         status_is_exported_to_non_submodules(Status0) = yes
     ->
-        TypeStr = describe_sym_name_and_arity(Name / Arity),
-        ErrorPieces = [
+        ForeignVisPieces = [
             words("Error: pragma foreign_type "),
-            fixed(TypeStr),
+            sym_name_and_arity(Name / Arity),
             words("must have the same visibility as the type declaration.")
         ],
-        write_error_pieces(Context, 0, ErrorPieces, !IO),
-        module_info_incr_errors(!ModuleInfo)
+        ForeignVisMsg = simple_msg(Context, [always(ForeignVisPieces)]),
+        ForeignVisSpec = error_spec(severity_error, phase_parse_tree_to_hlds,
+            [ForeignVisMsg]),
+        write_error_spec(ForeignVisSpec, 0, _ForeignVisNumWarnings,
+            0, ForeignVisNumErrors, !IO),
+        module_info_incr_num_errors(ForeignVisNumErrors, !ModuleInfo)
     ;
         % If there was an existing non-abstract definition for the type, ...
         MaybeOldDefn = yes(T2),
@@ -252,14 +256,16 @@
                 module_info_set_type_table(Types, !ModuleInfo)
             ;
                 module_info_incr_errors(!ModuleInfo),
-                Pieces = [words("In definition of type"),
-                    fixed(describe_sym_name_and_arity(Name / Arity) ++ ":"),
-                    nl,
-                    words("error: all definitions of a"),
-                    words("type must have the same"),
-                    words("visibility")],
-                write_error_pieces(Context, 0,
-                    Pieces, !IO)
+                DiffVisPieces = [words("In definition of type"),
+                    sym_name_and_arity(Name / Arity), suffix(":"), nl,
+                    words("error: all definitions of a type"),
+                    words("must have the same visibility")],
+                DiffVisMsg = simple_msg(Context, [always(DiffVisPieces)]),
+                DiffVisSpec = error_spec(severity_error,
+                    phase_parse_tree_to_hlds, [DiffVisMsg]),
+                write_error_spec(DiffVisSpec, 0, _DiffVisNumWarnings,
+                    0, DiffVisNumErrors, !IO),
+                module_info_incr_num_errors(DiffVisNumErrors, !ModuleInfo)
             )
         ;
             % ..., otherwise issue an error message if the second
@@ -285,20 +291,18 @@
             list.member(Var, Args),
             \+ type_contains_var(EqvType, Var)
         ->
-            Pieces = [words("Sorry, not implemented:"),
+            PolyEqvPieces = [words("Sorry, not implemented:"),
                 words("polymorphic equivalence type,"),
                 words("with monomorphic definition,"),
                 words("exported as abstract type.")],
-            write_error_pieces(Context, 0, Pieces, !IO),
-            (
-                VerboseErrors = yes,
-                write_error_pieces(Context, 0, abstract_monotype_workaround,
-                    !IO)
-            ;
-                VerboseErrors = no,
-                globals.io_set_extra_error_info(yes, !IO)
-            ),
-            io.set_exit_status(1, !IO)
+            PolyEqvMsg = simple_msg(Context,
+                [always(PolyEqvPieces),
+                verbose_only(abstract_monotype_workaround)]),
+            PolyEqvSpec = error_spec(severity_error, phase_parse_tree_to_hlds,
+                [PolyEqvMsg]),
+            write_error_spec(PolyEqvSpec, 0, _PolyEqvNumWarnings,
+                0, PolyEqvNumErrors, !IO),
+            module_info_incr_num_errors(PolyEqvNumErrors, !ModuleInfo)
         ;
             true
         )
@@ -452,39 +456,31 @@
     globals.get_target(Globals, Target),
     ( have_foreign_type_for_backend(Target, ForeignTypeBody, yes) ->
         FoundError = no
-    ; GeneratingCode = yes ->
-        %
-        % If we're not generating code the error may only have
-        % occurred because the grade options weren't passed.
-        %
-        io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
-        (
-            VeryVerbose = yes,
-            VerboseErrorPieces = [
-                nl,
-                words("There are representations for"),
-                words("this type on other back-ends,"),
-                words("but none for this back-end.")
-            ]
         ;
-            VeryVerbose = no,
-            VerboseErrorPieces = []
-        ),
+        (
+            GeneratingCode = yes,
         ( Target = target_c, LangStr = "C"
         ; Target = target_il, LangStr = "IL"
         ; Target = target_java, LangStr = "Java"
         ; Target = target_asm, LangStr = "C"
         ),
-        TypeStr = describe_sym_name_and_arity(Name/Arity),
-        ErrorPieces = [
-            words("Error: no"), words(LangStr),
-            words("`pragma foreign_type' declaration for"),
-            fixed(TypeStr) | VerboseErrorPieces
-        ],
-        write_error_pieces(Context, 0, ErrorPieces, !IO),
-        FoundError = yes,
-        module_info_incr_errors(!ModuleInfo)
-    ;
+            MainPieces = [words("Error: no"), fixed(LangStr),
+                fixed("`pragma foreign_type'"), words("declaration for"),
+                sym_name_and_arity(Name/Arity), nl],
+            VerbosePieces = [words("There are representations for this type"),
+                words("on other back-ends, but none for this back-end."), nl],
+            Msg = simple_msg(Context,
+                [always(MainPieces), 
+                option_is_set(very_verbose, yes, [always(VerbosePieces)])]),
+            Spec = error_spec(severity_error, phase_parse_tree_to_hlds,
+                [Msg]),
+            write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+            module_info_incr_num_errors(NumErrors, !ModuleInfo)
+        ;
+            GeneratingCode = no
+            % If we're not generating code the error may only have occurred
+            % because the grade options weren't passed.
+        ),
         FoundError = yes
     ).
 
@@ -714,18 +710,14 @@
         list.member(OtherConsDefn, QualifiedConsDefns1),
         OtherConsDefn = hlds_cons_defn(_, _, _, TypeCtor, _)
     ->
-        % XXX we should record each error using module_info_incr_errors
         QualifiedConsIdStr = cons_id_to_string(QualifiedConsId),
         TypeCtorStr = type_ctor_to_string(TypeCtor),
-        ErrMsg = [
-            words("Error: constructor"),
-            quote(QualifiedConsIdStr),
-            words("for type"),
-            quote(TypeCtorStr),
-            words("multiply defined.")
-        ],
-        write_error_pieces(Context, 0, ErrMsg, !IO),
-        io.set_exit_status(1, !IO),
+        Pieces = [words("Error: constructor"), quote(QualifiedConsIdStr),
+            words("for type"), quote(TypeCtorStr), words("multiply defined.")],
+        Msg = simple_msg(Context, [always(Pieces)]),
+        Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
+        write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO),
+        % XXX module_info_incr_errors(_NumErrors, !ModuleInfo)
         QualifiedConsDefns = QualifiedConsDefns1
     ;
         QualifiedConsDefns = [ConsDefn | QualifiedConsDefns1]
@@ -818,16 +810,18 @@
         % using module_info_incr_errors
         FieldDefn = hlds_ctor_field_defn(Context, _, _, _, _),
         sym_name_to_string(FieldName, FieldString),
-        ErrorPieces = [words("Error: field"), quote(FieldString),
+        Pieces = [words("Error: field"), quote(FieldString),
             words("multiply defined.")],
-        write_error_pieces(Context, 0, ErrorPieces, !IO),
-
+        Msg1 = simple_msg(Context, [always(Pieces)]),
         PrevPieces = [words("Here is the previous definition of field"),
             quote(FieldString), suffix(".")],
-        write_error_pieces_not_first_line(OrigContext, 0, PrevPieces, !IO),
-        io.set_exit_status(1, !IO)
+        Msg2 = simple_msg(OrigContext, [always(PrevPieces)]),
+        Spec = error_spec(severity_error, phase_parse_tree_to_hlds,
+            [Msg1, Msg2]),
+        write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO)
+        % XXX module_info_incr_errors(_NumErrors, !ModuleInfo)
     ;
-        unqualify_name(FieldName, UnqualFieldName),
+        UnqualFieldName = unqualify_name(FieldName),
 
         % Add an unqualified version of the field name to the table,
         % if appropriate.
Index: compiler/assertion.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/assertion.m,v
retrieving revision 1.53
diff -u -b -r1.53 assertion.m
--- compiler/assertion.m	20 Aug 2006 08:20:52 -0000	1.53
+++ compiler/assertion.m	6 Sep 2006 03:56:11 -0000
@@ -24,7 +24,6 @@
 :- import_module hlds.hlds_pred.
 :- import_module parse_tree.prog_data.
 
-:- import_module io.
 :- import_module pair.
 
 %-----------------------------------------------------------------------------%
@@ -123,13 +122,6 @@
 :- pred is_construction_equivalence_assertion(module_info::in, assert_id::in,
     cons_id::in, pred_id::in) is semidet.
 
-    % Ensure that an assertion which is defined in an interface
-    % doesn't refer to any constructors, functions and predicates
-    % defined in the implementation of that module.
-    %
-:- pred in_interface_check(hlds_goal::in, pred_info::in,
-    module_info::in, module_info::out, io::di, io::uo) is det.
-
     % Place a hlds_goal into a standard form.  Currently all the
     % code does is replace conj([G]) with G.
     %
@@ -143,13 +135,8 @@
 :- import_module check_hlds.type_util.
 :- import_module hlds.goal_util.
 :- import_module hlds.hlds_clauses.
-:- import_module hlds.hlds_out.
 :- import_module libs.compiler_util.
-:- import_module libs.globals.
-:- import_module libs.options.
 :- import_module mdbcomp.prim_data.
-:- import_module parse_tree.error_util.
-:- import_module parse_tree.prog_out.
 :- import_module parse_tree.prog_type.
 :- import_module parse_tree.prog_util.
 
@@ -720,168 +707,6 @@
     normalise_goals(Goal0s, Goals).
 
 %-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-
-in_interface_check(plain_call(PredId,_,_,_,_,SymName) - GoalInfo, _PredInfo,
-        !Module, !IO) :-
-    module_info_pred_info(!.Module, PredId, CallPredInfo),
-    pred_info_get_import_status(CallPredInfo, ImportStatus),
-    ( is_defined_in_implementation_section(ImportStatus) = yes ->
-        goal_info_get_context(GoalInfo, Context),
-        PredOrFunc = pred_info_is_pred_or_func(CallPredInfo),
-        Arity = pred_info_orig_arity(CallPredInfo),
-        IdStr = simple_call_id_to_string(PredOrFunc, SymName, Arity),
-        write_assertion_interface_error(Context, IdStr, !Module, !IO)
-    ;
-        true
-    ).
-in_interface_check(generic_call(_, _, _, _) - _, _, !Module, !IO).
-in_interface_check(unify(Var, RHS, _, _, _) - GoalInfo, PredInfo,
-        !Module, !IO) :-
-    goal_info_get_context(GoalInfo, Context),
-    in_interface_check_unify_rhs(RHS, Var, Context, PredInfo, !Module, !IO).
-in_interface_check(call_foreign_proc(_, PredId, _, _, _, _, _) -
-        GoalInfo, _PredInfo, !Module, !IO) :-
-    module_info_pred_info(!.Module, PredId, PragmaPredInfo),
-    pred_info_get_import_status(PragmaPredInfo, ImportStatus),
-    ( is_defined_in_implementation_section(ImportStatus) = yes ->
-        goal_info_get_context(GoalInfo, Context),
-        PredOrFunc = pred_info_is_pred_or_func(PragmaPredInfo),
-        Name = pred_info_name(PragmaPredInfo),
-        SymName = unqualified(Name),
-        Arity = pred_info_orig_arity(PragmaPredInfo),
-        IdStr = simple_call_id_to_string(PredOrFunc, SymName, Arity),
-        write_assertion_interface_error(Context, IdStr, !Module, !IO)
-    ;
-        true
-    ).
-in_interface_check(conj(_, Goals) - _, PredInfo, !Module, !IO) :-
-    in_interface_check_list(Goals, PredInfo, !Module, !IO).
-in_interface_check(switch(_, _, _) - _, _, _, _, !IO) :-
-    unexpected(this_file, "in_interface_check: assertion contains switch.").
-in_interface_check(disj(Goals) - _, PredInfo, !Module, !IO) :-
-    in_interface_check_list(Goals, PredInfo, !Module, !IO).
-in_interface_check(negation(Goal) - _, PredInfo, !Module, !IO) :-
-    in_interface_check(Goal, PredInfo, !Module, !IO).
-in_interface_check(scope(_, Goal) - _, PredInfo, !Module, !IO) :-
-    in_interface_check(Goal, PredInfo, !Module, !IO).
-in_interface_check(if_then_else(_, If, Then, Else) - _, PredInfo,
-        !Module, !IO) :-
-    in_interface_check(If, PredInfo, !Module, !IO),
-    in_interface_check(Then, PredInfo, !Module, !IO),
-    in_interface_check(Else, PredInfo, !Module, !IO).
-in_interface_check(shorthand(ShorthandGoal) - _GoalInfo, PredInfo,
-        !Module, !IO) :-
-    in_interface_check_shorthand(ShorthandGoal, PredInfo, !Module, !IO).
-
-:- pred in_interface_check_shorthand(shorthand_goal_expr::in,
-    pred_info::in, module_info::in, module_info::out, io::di, io::uo) is det.
-
-in_interface_check_shorthand(bi_implication(LHS, RHS), PredInfo,
-        !Module, !IO) :-
-    in_interface_check(LHS, PredInfo, !Module, !IO),
-    in_interface_check(RHS, PredInfo, !Module, !IO).
-
-%-----------------------------------------------------------------------------%
-
-:- pred in_interface_check_unify_rhs(unify_rhs::in, prog_var::in,
-    prog_context::in, pred_info::in, module_info::in, module_info::out,
-    io::di, io::uo) is det.
-
-in_interface_check_unify_rhs(rhs_var(_), _, _, _, !Module, !IO).
-in_interface_check_unify_rhs(rhs_functor(ConsId, _, _), Var, Context,
-        PredInfo, !Module, !IO) :-
-    pred_info_clauses_info(PredInfo, ClausesInfo),
-    clauses_info_get_vartypes(ClausesInfo, VarTypes),
-    map.lookup(VarTypes, Var, Type),
-    ( type_to_ctor_and_args(Type, TypeCtor, _) ->
-        module_info_get_type_table(!.Module, Types),
-        map.lookup(Types, TypeCtor, TypeDefn),
-        hlds_data.get_type_defn_status(TypeDefn, TypeStatus),
-        ( is_defined_in_implementation_section(TypeStatus) = yes ->
-            ConsIdStr = cons_id_to_string(ConsId),
-            IdStr = "constructor `" ++ ConsIdStr ++ "'",
-            write_assertion_interface_error(Context, IdStr, !Module, !IO)
-        ;
-            true
-        )
-    ;
-        unexpected(this_file,
-            "in_interface_check_unify_rhs: type_to_ctor_and_args failed.")
-    ).
-in_interface_check_unify_rhs(rhs_lambda_goal(_, _, _, _, _, _, _, Goal),
-        _Var, _Context, PredInfo, !Module, !IO) :-
-    in_interface_check(Goal, PredInfo, !Module, !IO).
-
-%-----------------------------------------------------------------------------%
-
-:- pred in_interface_check_list(hlds_goals::in, pred_info::in,
-    module_info::in, module_info::out, io::di, io::uo)is det.
-
-in_interface_check_list([], _, !Module, !IO).
-in_interface_check_list([Goal0 | Goal0s], PredInfo, !Module, !IO) :-
-    in_interface_check(Goal0, PredInfo, !Module, !IO),
-    in_interface_check_list(Goal0s, PredInfo, !Module, !IO).
-
-%-----------------------------------------------------------------------------%
-
-    % Returns yes if the import_status indicates the item came form
-    % the implementation section.
-    %
-:- func is_defined_in_implementation_section(import_status) = bool.
-
-is_defined_in_implementation_section(status_abstract_exported) = yes.
-is_defined_in_implementation_section(status_exported_to_submodules) = yes.
-is_defined_in_implementation_section(status_local) = yes.
-is_defined_in_implementation_section(status_opt_imported) = no.
-is_defined_in_implementation_section(status_abstract_imported) = no.
-is_defined_in_implementation_section(status_pseudo_imported) = no.
-is_defined_in_implementation_section(status_exported) = no.
-is_defined_in_implementation_section(status_opt_exported) = yes.
-is_defined_in_implementation_section(status_pseudo_exported) = no.
-is_defined_in_implementation_section(status_external(Status)) =
-    is_defined_in_implementation_section(Status).
-is_defined_in_implementation_section(status_imported(ImportLocn)) = Impl :-
-    (
-        ImportLocn = import_locn_implementation,
-        Impl = yes
-    ;
-        ( ImportLocn = import_locn_interface
-        ; ImportLocn = import_locn_ancestor
-        ; ImportLocn = import_locn_ancestor_private_interface
-        ),
-        Impl = yes
-    ).
-
-%-----------------------------------------------------------------------------%
-
-:- pred write_assertion_interface_error(prog_context::in, string::in,
-    module_info::in, module_info::out, io::di, io::uo) is det.
-
-write_assertion_interface_error(Context, IdStr, !Module, !IO) :-
-    module_info_incr_errors(!Module),
-    module_info_get_name(!.Module, ModuleName),
-    ModuleStr = describe_sym_name(ModuleName),
-    write_error_pieces(Context, 0,
-        [words("In interface for module"), fixed(ModuleStr ++ ":")], !IO),
-    write_error_pieces_not_first_line(Context, 0,
-        [words("error: exported promise refers to"),
-        words(IdStr), words("which is defined in the "),
-        words("implementation section of module"),
-        fixed(ModuleStr ++ ".")], !IO),
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
-        write_error_pieces_not_first_line(Context, 0,
-            [words("Either move the promise into the "),
-            words("implementation section or move "),
-            words("the definition into the interface.")], !IO)
-    ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO)
-    ).
-
-%-----------------------------------------------------------------------------%
 
 :- func this_file = string.
 
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.97
diff -u -b -r1.97 check_typeclass.m
--- compiler/check_typeclass.m	22 Aug 2006 05:03:38 -0000	1.97
+++ compiler/check_typeclass.m	5 Sep 2006 14:58:39 -0000
@@ -191,12 +191,10 @@
 :- pred check_one_class(class_table::in,
     pair(class_id, list(hlds_instance_defn))::in,
     pair(class_id, list(hlds_instance_defn))::out,
-    check_tc_info::in, check_tc_info::out,
-    io::di, io::uo) is det.
+    check_tc_info::in, check_tc_info::out, io::di, io::uo) is det.
 
 check_one_class(ClassTable, ClassId - InstanceDefns0,
     ClassId - InstanceDefns, !CheckTCInfo, !IO) :-
-
     map.lookup(ClassTable, ClassId, ClassDefn),
     ClassDefn = hlds_class_defn(ImportStatus, SuperClasses, _FunDeps,
         _Ancestors, ClassVars, _Kinds, Interface, ClassInterface,
@@ -242,7 +240,6 @@
         check_tc_info(Errors0, ModuleInfo0, QualInfo0),
         check_tc_info(Errors, ModuleInfo, QualInfo),
         !IO):-
-
     % Check conformance of the instance body.
     !.InstanceDefn = hlds_instance_defn(_, _, TermContext, _, _,
         InstanceBody, _, _, _),
@@ -376,10 +373,7 @@
 format_method_name(Method) = MethodName :-
     Method = instance_method(PredOrFunc, Name, _Defn, Arity, _Context),
     adjust_func_arity(PredOrFunc, Arity, PredArity),
-    MethodName = [
-        pred_or_func(PredOrFunc),
-        sym_name_and_arity(Name / PredArity)
-    ].
+    MethodName = [p_or_f(PredOrFunc), sym_name_and_arity(Name / PredArity)].
 
 %----------------------------------------------------------------------------%
 
@@ -426,8 +420,7 @@
     %
 :- pred check_instance_pred(class_id::in, list(tvar)::in,
     hlds_class_interface::in, pred_id::in,
-    instance_check_info::in, instance_check_info::out,
-    io::di, io::uo) is det.
+    instance_check_info::in, instance_check_info::out, io::di, io::uo) is det.
 
 check_instance_pred(ClassId, ClassVars, ClassInterface, PredId,
         !InstanceCheckInfo, !IO) :-
@@ -549,23 +542,20 @@
         OrderedInstanceMethods = OrderedInstanceMethods0,
         InstanceDefn = InstanceDefn0,
         ClassId = class_id(ClassName, _ClassArity),
-        sym_name_to_string(MethodName, MethodNameString),
         sym_name_to_string(ClassName, ClassNameString),
-        PredOrFuncString = pred_or_func_to_string(PredOrFunc),
-        string.int_to_string(Arity, ArityString),
         InstanceTypesString = mercury_type_list_to_string(InstanceVarSet,
             InstanceTypes),
-        string.append_list([
-            "In instance declaration for `",
-            ClassNameString, "(", InstanceTypesString, ")': ",
-            "multiple implementations of type class ",
-            PredOrFuncString, " method `",
-            MethodNameString, "/", ArityString, "'."],
-            ErrorHeader),
+        ErrorHeaderPieces =
+            [words("In instance declaration for"),
+            fixed("`" ++ ClassNameString ++ "'("
+                ++ InstanceTypesString ++ "):"),
+            words("multiple implementations of type class"),
+            p_or_f(PredOrFunc), words("method"),
+            sym_name_and_arity(MethodName / Arity), suffix(".")],
         I1 = instance_method(_, _, _, _, I1Context),
         Heading =
             [I1Context - [words("First definition appears here.")],
-            InstanceContext - [words(ErrorHeader)]],
+            InstanceContext - ErrorHeaderPieces],
         list.map((pred(Definition::in, ContextAndError::out) is det :-
             Definition = instance_method(_, _, _, _, TheContext),
             Error = [words("Subsequent definition appears here.")],
@@ -589,21 +579,16 @@
             InstanceTypes),
 
         Error = [words("In instance declaration for"),
-            fixed("`" ++ ClassNameString
-                ++ "(" ++ InstanceTypesString
-                ++ ")'"),
+            quote(ClassNameString ++ "(" ++ InstanceTypesString ++ ")"),
             suffix(":"),
-            words("no implementation for type class"),
-            pred_or_func(PredOrFunc),
-            words("method"),
-            sym_name_and_arity(MethodName / Arity),
+            words("no implementation for type class"), p_or_f(PredOrFunc),
+            words("method"), sym_name_and_arity(MethodName / Arity),
             suffix(".")
         ],
         Errors = [InstanceContext - Error | Errors0],
         Info = instance_method_info(ModuleInfo, QualInfo, PredName,
             Arity, ExistQVars, ArgTypes, ClassContext,
-            ArgModes, Errors,
-            ArgTypeVars, Status, PredOrFunc)
+            ArgModes, Errors, ArgTypeVars, Status, PredOrFunc)
     ).
 
     % Get all the instance definitions which match the specified
@@ -637,7 +622,8 @@
         % combine them all into a single definition.
         MethodToClause = (pred(Method::in, Clauses::out) is semidet :-
             Method = instance_method(_, _, Defn, _, _),
-            Defn = clauses(Clauses)),
+            Defn = clauses(Clauses)
+        ),
         list.filter_map(MethodToClause, MatchingMethods, ClausesList),
         list.condense(ClausesList, FlattenedClauses),
         CombinedMethod = instance_method(PredOrFunc, MethodName,
@@ -761,9 +747,9 @@
 
     module_info_get_predicate_table(ModuleInfo1, PredicateTable1),
     module_info_get_partial_qualifier_info(ModuleInfo1, PQInfo),
-    % XXX Why do we need to pass may_be_unqualified here,
-    % rather than passing must_be_qualified or calling the /4 version?
-    predicate_table_insert(PredInfo, may_be_unqualified, PQInfo, PredId,
+    % XXX Why do we need to pass may_be_unqualified here, rather than passing
+    % must_be_qualified or calling the predicate_table_insert/4 version?
+    predicate_table_insert_qual(PredInfo, may_be_unqualified, PQInfo, PredId,
         PredicateTable1, PredicateTable),
     module_info_set_predicate_table(PredicateTable, ModuleInfo1, ModuleInfo),
 
@@ -1663,7 +1649,7 @@
         Vars),
 
     Msg0 = [words("In declaration for"),
-        words(simple_call_id_to_string(PredOrFunc, SymName, Arity)),
+        simple_call(simple_call_id(PredOrFunc, SymName, Arity)),
         suffix(":"), nl,
         words("error in type class constraints:"),
         words(choose_number(Vars, "type variable", "type variables"))]
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.71
diff -u -b -r1.71 deforest.m
--- compiler/deforest.m	22 Aug 2006 05:03:42 -0000	1.71
+++ compiler/deforest.m	7 Sep 2006 00:44:05 -0000
@@ -1719,7 +1719,7 @@
     pd_info_get_proc_arg_info(!.PDInfo, ProcArgInfos),
     pd_info_get_module_info(!.PDInfo, ModuleInfo),
     pd_info_get_instmap(!.PDInfo, InstMap),
-    unqualify_name(SymName, Name),
+    Name = unqualify_name(SymName),
     list.length(Args, Arity),
     Goal0 = GoalExpr0 - GoalInfo0,
     goal_info_get_context(GoalInfo0, Context),
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.126
diff -u -b -r1.126 det_report.m
--- compiler/det_report.m	22 Aug 2006 05:03:42 -0000	1.126
+++ compiler/det_report.m	7 Sep 2006 04:57:07 -0000
@@ -224,12 +224,14 @@
     proc_info_get_declared_determinism(ProcInfo0, MaybeDetism),
     proc_info_get_inferred_determinism(ProcInfo0, InferredDetism),
     (
-        MaybeDetism = no
+        MaybeDetism = no,
+        CmpSpecs = []
     ;
         MaybeDetism = yes(DeclaredDetism),
         compare_determinisms(DeclaredDetism, InferredDetism, Cmp),
         (
-            Cmp = sameas
+            Cmp = sameas,
+            CmpSpecs = []
         ;
             Cmp = looser,
             globals.io_lookup_bool_option(warn_det_decls_too_lax,
@@ -268,27 +270,29 @@
             ->
                 Message = "warning: determinism declaration " ++
                     "could be tighter.\n",
-                record_warning(!IO),
                 report_determinism_problem(PredId, ProcId, !.ModuleInfo,
-                    Message, DeclaredDetism, InferredDetism, ReportSpec),
-                write_error_specs([ReportSpec], !IO)
+                    Message, DeclaredDetism, InferredDetism, ReportMsgs),
+                ReportSpec = error_spec(severity_warning, phase_detism_check,
+                    ReportMsgs),
+                CmpSpecs = [ReportSpec]
             ;
-                true
+                CmpSpecs = []
             )
         ;
             Cmp = tighter,
-            module_info_incr_errors(!ModuleInfo),
-            Message = "  error: determinism declaration not satisfied.\n",
-            record_warning(!IO),
+            Message = "error: determinism declaration not satisfied.\n",
             report_determinism_problem(PredId, ProcId, !.ModuleInfo, Message,
-                DeclaredDetism, InferredDetism, ReportSpec),
+                DeclaredDetism, InferredDetism, ReportMsgs),
             proc_info_get_goal(ProcInfo0, Goal),
             proc_info_get_vartypes(ProcInfo0, VarTypes),
             globals.io_get_globals(Globals, !IO),
             det_info_init(!.ModuleInfo, VarTypes, PredId, ProcId, Globals,
                 DetInfo),
-            det_diagnose_goal(Goal, DeclaredDetism, [], DetInfo, _, [], Specs),
-            write_error_specs([ReportSpec | Specs], !IO)
+            det_diagnose_goal(Goal, DeclaredDetism, [], DetInfo, GoalMsgs0),
+            sort_error_msgs(GoalMsgs0, GoalMsgs),
+            ReportSpec = error_spec(severity_error, phase_detism_check,
+                ReportMsgs ++ GoalMsgs),
+            CmpSpecs = [ReportSpec]
         )
     ),
 
@@ -299,18 +303,17 @@
         pred_info_get_procedures(PredInfo0, ProcTable0),
         map.det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
         pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
-        module_info_set_pred_info(PredId, PredInfo, !ModuleInfo)
+        module_info_set_pred_info(PredId, PredInfo, !ModuleInfo),
+        ValidSpecs = []
     ;
         proc_info_get_context(ProcInfo0, Context),
-        write_error_pieces(Context, 0,
+        MainPieces =
             [words("Error: `pragma "
                 ++ eval_method_to_string(EvalMethod) ++ "'"),
             words("declaration not allowed for procedure"),
-            words("with determinism `"
-                ++ determinism_to_string(InferredDetism) ++ "'.")], !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
+            words("with determinism"),
+            quote(determinism_to_string(InferredDetism)), suffix(".")],
+
             solutions.solutions(get_valid_dets(EvalMethod), Detisms),
             DetismStrs = list.map(determinism_to_string, Detisms),
             list.sort(DetismStrs, SortedDetismStrs),
@@ -320,16 +323,17 @@
                 Plural = "s"
             ),
             DetismPieces = list_to_pieces(SortedDetismStrs),
-            write_error_pieces_not_first_line(Context, 0,
+        VerbosePieces =
                 [words("The pragma requested is only valid"),
                 words("for the following determinism" ++ Plural ++ ":") |
-                DetismPieces] ++ [suffix(".")], !IO)
-        ;
-            VerboseErrors = no,
-            globals.io_set_extra_error_info(yes, !IO)
-        ),
-        module_info_incr_errors(!ModuleInfo)
-    ).
+            DetismPieces] ++ [suffix("."), nl],
+        ValidSpecs = [error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context,
+                [always(MainPieces), verbose_only(VerbosePieces)])])]
+    ),
+    write_error_specs(CmpSpecs ++ ValidSpecs, 0, _NumWarnings, 0, NumErrors,
+        !IO),
+    module_info_incr_num_errors(NumErrors, !ModuleInfo).
 
 :- pred get_valid_dets(eval_method::in, determinism::out) is nondet.
 
@@ -372,10 +376,12 @@
             DeclaredDetism = detism_cc_multi
         )
     ->
-        proc_info_get_context(ProcInfo, Context1),
-        write_error_pieces(Context1, 0,
-            [words("Error: main/2 must be `det' or `cc_multi'.")], !IO),
-        module_info_incr_errors(!ModuleInfo)
+        proc_info_get_context(ProcInfo, ProcContext),
+        Pieces = [words("Error: main/2 must be `det' or `cc_multi'.")],
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(ProcContext, [always(Pieces)])]),
+        write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+        module_info_incr_num_errors(NumErrors, !ModuleInfo)
     ;
         true
     ).
@@ -392,7 +398,7 @@
     % transparent.  (Nondeterministic "functions" like C's `rand()'
     % function are not allowed.)
     (
-        % if it is a mode for a function...
+        % If it is a mode for a function...
         pred_info_is_pred_or_func(PredInfo) = function,
         % ... that can succeed more than once ...
         determinism_components(InferredDetism, _CanFail, NumSolns),
@@ -411,21 +417,16 @@
         proc_info_get_inst_varset(ProcInfo, InstVarSet),
         PredModePieces = describe_one_pred_name_mode(!.ModuleInfo,
             should_not_module_qualify, PredId, InstVarSet, PredArgModes),
-        Pieces = [words("Error: invalid determinism for")]
+        MainPieces = [words("Error: invalid determinism for")]
             ++ PredModePieces ++ [suffix(":"), nl,
             words("the primary mode of a function cannot be"),
-            words("`" ++ mercury_det_to_string(InferredDetism) ++ "'.")],
-        write_error_pieces(FuncContext, 0, Pieces, !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            write_error_pieces_not_first_line(FuncContext, 0,
-                func_primary_mode_det_msg, !IO)
-        ;
-            VerboseErrors = no,
-            globals.io_set_extra_error_info(yes, !IO)
-        ),
-        module_info_incr_errors(!ModuleInfo)
+            quote(mercury_det_to_string(InferredDetism)), suffix(".")],
+        VerbosePieces = func_primary_mode_det_msg,
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(FuncContext,
+                [always(MainPieces), verbose_only(VerbosePieces)])]),
+        write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+        module_info_incr_num_errors(NumErrors, !ModuleInfo)
     ;
         true
     ).
@@ -463,21 +464,21 @@
     ).
 
 :- pred report_determinism_problem(pred_id::in, proc_id::in, module_info::in,
-    string::in, determinism::in, determinism::in,
-    error_msg_spec::out) is det.
+    string::in, determinism::in, determinism::in, list(error_msg)::out) is det.
 
 report_determinism_problem(PredId, ProcId, ModuleInfo, Message,
-        DeclaredDetism, InferredDetism, Spec) :-
+        DeclaredDetism, InferredDetism, Msgs) :-
     module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo),
     proc_info_get_context(ProcInfo, Context),
     ProcPieces = describe_one_proc_name_mode(ModuleInfo,
         should_not_module_qualify, proc(PredId, ProcId)),
     Pieces = [words("In")] ++ ProcPieces ++ [suffix(":"), nl,
         words(Message), nl,
-        words("Declared `" ++ determinism_to_string(DeclaredDetism)
-            ++ "', inferred `" ++ determinism_to_string(InferredDetism)
-            ++ "'.")],
-    Spec = error_msg_spec(no, Context, 0, Pieces).
+        words("Declared"),
+        quote(determinism_to_string(DeclaredDetism)), suffix(","),
+        words("inferred"),
+        quote(determinism_to_string(InferredDetism)), suffix(".")],
+    Msgs = [simple_msg(Context, [always(Pieces)])].
 
 %-----------------------------------------------------------------------------%
 
@@ -537,34 +538,31 @@
     % Find out what is wrong and print a report of the cause.
     %
 :- pred det_diagnose_goal(hlds_goal::in, determinism::in,
-    list(switch_context)::in, det_info::in, bool::out,
-    list(error_msg_spec)::in, list(error_msg_spec)::out) is det.
+    list(switch_context)::in, det_info::in, list(error_msg)::out) is det.
 
-det_diagnose_goal(Goal - GoalInfo, Desired, SwitchContext, DetInfo, Diagnosed,
-        !Specs) :-
+det_diagnose_goal(Goal - GoalInfo, Desired, SwitchContext, DetInfo, Msgs) :-
     goal_info_get_determinism(GoalInfo, Actual),
     ( compare_determinisms(Desired, Actual, tighter) ->
         det_diagnose_goal_2(Goal, GoalInfo, Desired, Actual, SwitchContext,
-            DetInfo, Diagnosed, !Specs)
+            DetInfo, Msgs)
     ;
-        Diagnosed = no
+        Msgs = []
     ).
 
 %-----------------------------------------------------------------------------%
 
 :- pred det_diagnose_goal_2(hlds_goal_expr::in, hlds_goal_info::in,
     determinism::in, determinism::in, list(switch_context)::in,
-    det_info::in, bool::out,
-    list(error_msg_spec)::in, list(error_msg_spec)::out) is det.
+    det_info::in, list(error_msg)::out) is det.
 
 det_diagnose_goal_2(conj(_, Goals), _GoalInfo, Desired, _Actual, Context,
-        DetInfo, Diagnosed, !Specs) :-
-    det_diagnose_conj(Goals, Desired, Context, DetInfo, Diagnosed, !Specs).
+        DetInfo, Msgs) :-
+    det_diagnose_conj(Goals, Desired, Context, DetInfo, Msgs).
 
 det_diagnose_goal_2(disj(Goals), GoalInfo, Desired, Actual, SwitchContext,
-        DetInfo, Diagnosed, !Specs) :-
+        DetInfo, Msgs) :-
     det_diagnose_disj(Goals, Desired, Actual, SwitchContext, DetInfo, 0,
-        ClausesWithSoln, Diagnosed1, !Specs),
+        ClausesWithSoln, Msgs1),
     determinism_components(Desired, _, DesSolns),
     (
         DesSolns \= at_most_many,
@@ -573,11 +571,10 @@
     ->
         goal_info_get_context(GoalInfo, Context),
         Pieces = [words("Disjunction has multiple clauses with solutions.")],
-        Spec = error_msg_spec(no, Context, 0, Pieces),
-        inst_preserving_append(!.Specs, [Spec], !:Specs),
-        Diagnosed = yes
+        Msg = simple_msg(Context, [always(Pieces)]),
+        Msgs = [Msg] ++ Msgs1
     ;
-        Diagnosed = Diagnosed1
+        Msgs = Msgs1
     ).
 
     % The determinism of a switch is the worst of the determinism of each of
@@ -586,13 +583,13 @@
     % in switch_detection.m and handled via the CanFail field.
     %
 det_diagnose_goal_2(switch(Var, SwitchCanFail, Cases), GoalInfo,
-        Desired, _Actual, SwitchContext, DetInfo, Diagnosed, !Specs) :-
+        Desired, _Actual, SwitchContext, DetInfo, Msgs) :-
     (
         SwitchCanFail = can_fail,
         determinism_components(Desired, cannot_fail, _)
     ->
         goal_info_get_context(GoalInfo, Context),
-        det_diagnose_switch_context(Context, SwitchContext, DetInfo, !Specs),
+        det_diagnose_switch_context(SwitchContext, DetInfo, NestingPieces),
         det_get_proc_info(DetInfo, ProcInfo),
         proc_info_get_varset(ProcInfo, VarSet),
         det_info_get_module_info(DetInfo, ModuleInfo),
@@ -611,40 +608,39 @@
             Pieces = [words("The switch on "), fixed(VarStr),
                 words("can fail.")]
         ),
-        Spec = error_msg_spec(no, Context, 0, Pieces),
-        inst_preserving_append(!.Specs, [Spec], !:Specs),
-        Diagnosed1 = yes
-    ;
-        Diagnosed1 = no
-    ),
-    det_diagnose_switch(Var, Cases, Desired, SwitchContext, DetInfo,
-        Diagnosed2, !Specs),
-    bool.or(Diagnosed1, Diagnosed2, Diagnosed).
+        Msgs1 = [simple_msg(Context, [always(NestingPieces ++ Pieces)])]
+    ;
+        Msgs1 = []
+    ),
+    det_diagnose_switch(Var, Cases, Desired, SwitchContext, DetInfo, Msgs2),
+    Msgs = Msgs1 ++ Msgs2.
 
 det_diagnose_goal_2(plain_call(PredId, ProcId, _, _, CallContext, _), GoalInfo,
-        Desired, Actual, _, DetInfo, yes, !Specs) :-
+        Desired, Actual, _, DetInfo, Msgs) :-
     goal_info_get_context(GoalInfo, Context),
     det_report_call_context(Context, CallContext, DetInfo, PredId, ProcId,
-        InitSpecs, Spec),
-    det_diagnose_atomic_goal(Desired, Actual, InitSpecs, Spec, !Specs).
+        InitMsgs, StartingPieces),
+    det_diagnose_atomic_goal(Desired, Actual, Context, StartingPieces,
+        AtomicMsgs),
+    Msgs = InitMsgs ++ AtomicMsgs.
 
 det_diagnose_goal_2(generic_call(GenericCall, _, _, _), GoalInfo,
-        Desired, Actual, _, _DetInfo, yes, !Specs) :-
+        Desired, Actual, _, _DetInfo, Msgs) :-
     goal_info_get_context(GoalInfo, Context),
-    report_generic_call_context(Context, GenericCall, Spec),
-    det_diagnose_atomic_goal(Desired, Actual, [], Spec, !Specs).
+    report_generic_call_context(GenericCall, StartingPieces),
+    det_diagnose_atomic_goal(Desired, Actual, Context, StartingPieces, Msgs).
 
 det_diagnose_goal_2(unify(LHS, RHS, _, _, UnifyContext), GoalInfo,
-        Desired, Actual, _, DetInfo, yes, !Specs) :-
+        Desired, Actual, _, DetInfo, Msgs) :-
     goal_info_get_context(GoalInfo, Context),
     First = yes,
     Last = yes,
     det_report_unify_context(First, Last, Context, UnifyContext,
-        DetInfo, LHS, RHS, Spec),
-    det_diagnose_atomic_goal(Desired, Actual, [], Spec, !Specs).
+        DetInfo, LHS, RHS, StartingPieces),
+    det_diagnose_atomic_goal(Desired, Actual, Context, StartingPieces, Msgs).
 
 det_diagnose_goal_2(if_then_else(_Vars, Cond, Then, Else), _GoalInfo,
-        Desired, _Actual, SwitchContext, DetInfo, Diagnosed, !Specs) :-
+        Desired, _Actual, SwitchContext, DetInfo, Msgs) :-
     determinism_components(Desired, _DesiredCanFail, DesiredSolns),
     Cond = _CondGoal - CondInfo,
     goal_info_get_determinism(CondInfo, CondDetism),
@@ -654,20 +650,15 @@
         DesiredSolns \= at_most_many
     ->
         determinism_components(DesiredCond, can_fail, DesiredSolns),
-        det_diagnose_goal(Cond, DesiredCond, SwitchContext, DetInfo,
-            Diagnosed1, !Specs)
+        det_diagnose_goal(Cond, DesiredCond, SwitchContext, DetInfo, Msgs1)
     ;
-        Diagnosed1 = no
+        Msgs1 = []
     ),
-    det_diagnose_goal(Then, Desired, SwitchContext, DetInfo, Diagnosed2,
-        !Specs),
-    det_diagnose_goal(Else, Desired, SwitchContext, DetInfo, Diagnosed3,
-        !Specs),
-    bool.or(Diagnosed2, Diagnosed3, Diagnosed23),
-    bool.or(Diagnosed1, Diagnosed23, Diagnosed).
+    det_diagnose_goal(Then, Desired, SwitchContext, DetInfo, Msgs2),
+    det_diagnose_goal(Else, Desired, SwitchContext, DetInfo, Msgs3),
+    Msgs = Msgs1 ++ Msgs2 ++ Msgs3.
 
-det_diagnose_goal_2(negation(_), GoalInfo, Desired, Actual, _, _, Diagnosed,
-        !Specs) :-
+det_diagnose_goal_2(negation(_), GoalInfo, Desired, Actual, _, _, Msgs) :-
     determinism_components(Desired, DesiredCanFail, DesiredSolns),
     determinism_components(Actual, ActualCanFail, ActualSolns),
     (
@@ -676,24 +667,20 @@
     ->
         goal_info_get_context(GoalInfo, Context),
         Pieces = [words("Negated goal can succeed.")],
-        Spec = error_msg_spec(no, Context, 0, Pieces),
-        inst_preserving_append(!.Specs, [Spec], !:Specs),
-        Diagnosed = yes
+        Msgs = [simple_msg(Context, [always(Pieces)])]
     ;
         DesiredSolns = at_most_zero,
         ActualSolns \= at_most_zero
     ->
         goal_info_get_context(GoalInfo, Context),
         Pieces = [words("Negated goal can fail.")],
-        Spec = error_msg_spec(no, Context, 0, Pieces),
-        inst_preserving_append(!.Specs, [Spec], !:Specs),
-        Diagnosed = yes
+        Msgs = [simple_msg(Context, [always(Pieces)])]
     ;
-        Diagnosed = no
+        Msgs = []
     ).
 
-det_diagnose_goal_2(scope(_, Goal), _, Desired, Actual,
-        SwitchContext, DetInfo, Diagnosed, !Specs) :-
+det_diagnose_goal_2(scope(_, Goal), _, Desired, Actual, SwitchContext, DetInfo,
+        Msgs) :-
     Goal = _ - GoalInfo,
     goal_info_get_determinism(GoalInfo, Internal),
     ( Actual = Internal ->
@@ -702,129 +689,113 @@
         determinism_components(Desired, CanFail, _),
         determinism_components(InternalDesired, CanFail, at_most_many)
     ),
-    det_diagnose_goal(Goal, InternalDesired, SwitchContext, DetInfo, Diagnosed,
-        !Specs).
+    det_diagnose_goal(Goal, InternalDesired, SwitchContext, DetInfo, Msgs).
 
 det_diagnose_goal_2(call_foreign_proc(_, _, _, _, _, _, _), GoalInfo, Desired,
-        _, _, _, yes, !Specs) :-
+        _, _, _, Msgs) :-
     goal_info_get_context(GoalInfo, Context),
     DesiredStr = determinism_to_string(Desired),
     Pieces = [words("Determinism declaration not satisfied."),
         words("Desired determinism is " ++ DesiredStr ++ ".")],
-    Spec = error_msg_spec(no, Context, 0, Pieces),
-    inst_preserving_append(!.Specs, [Spec], !:Specs).
+    Msgs = [simple_msg(Context, [always(Pieces)])].
 
-det_diagnose_goal_2(shorthand(_), _, _, _, _, _, _, !Specs) :-
+det_diagnose_goal_2(shorthand(_), _, _, _, _, _, []) :-
     % These should have been expanded out by now.
     unexpected(this_file, "det_diagnose_goal_2: unexpected shorthand").
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_generic_call_context(prog_context::in, generic_call::in,
-    error_msg_spec::out) is det.
+:- pred report_generic_call_context(generic_call::in,
+    list(format_component)::out) is det.
 
-report_generic_call_context(Context, CallType, Spec) :-
+report_generic_call_context(CallType, StartingPieces) :-
     hlds_goal.generic_call_id(CallType, CallId),
-    Pieces = [words(call_id_to_string(CallId))],
-    Spec = error_msg_spec(no, Context, 0, Pieces).
+    StartingPieces = [words(call_id_to_string(CallId))].
 
 %-----------------------------------------------------------------------------%
 
 :- pred det_diagnose_atomic_goal(determinism::in, determinism::in,
-    list(error_msg_spec)::in, error_msg_spec::in,
-    list(error_msg_spec)::in, list(error_msg_spec)::out) is det.
+    prog_context::in, list(format_component)::in, list(error_msg)::out) is det.
 
-det_diagnose_atomic_goal(Desired, Actual, InitSpecs, !.CurSpec, !Specs) :-
+det_diagnose_atomic_goal(Desired, Actual, Context, StartingPieces, Msgs) :-
     determinism_components(Desired, DesiredCanFail, DesiredSolns),
     determinism_components(Actual, ActualCanFail, ActualSolns),
     compare_canfails(DesiredCanFail, ActualCanFail, CmpCanFail),
     ( CmpCanFail = tighter ->
-        add_to_spec_at_end([words("can fail")], !CurSpec),
-        Diagnosed1 = yes
+        CanFailPieces = [words("can fail")]
     ;
-        Diagnosed1 = no
+        CanFailPieces = []
     ),
     compare_solncounts(DesiredSolns, ActualSolns, CmpSolns),
     ( CmpSolns = tighter ->
         (
-            Diagnosed1 = yes,
-            add_to_spec_at_end([words("and")], !CurSpec)
+            CanFailPieces = [_ | _],
+            ConnectPieces = [words("and")]
         ;
-            Diagnosed1 = no
+            CanFailPieces = [],
+            ConnectPieces = []
         ),
         ( DesiredSolns = at_most_one ->
-            add_to_spec_at_end([words("can succeed more than once")],
-                !CurSpec)
+            SolnsPieces = [words("can succeed more than once")]
         ;
-            add_to_spec_at_end([words("can succeed")], !CurSpec)
-        ),
-        Diagnosed2 = yes
+            SolnsPieces = [words("can succeed")]
+        )
     ;
-        Diagnosed2 = no
+        ConnectPieces = [],
+        SolnsPieces = []
     ),
-    bool.or(Diagnosed1, Diagnosed2, Diagnosed),
+    RawPieces = CanFailPieces ++ ConnectPieces ++ SolnsPieces,
     (
-        Diagnosed = yes,
-        add_to_spec_at_end([suffix("."), nl], !CurSpec)
+        RawPieces = [_ | _],
+        Pieces = RawPieces ++ [suffix("."), nl]
     ;
-        Diagnosed = no,
+        RawPieces = [],
         Pieces = [words("has unknown determinism problem;"), nl,
-            words("desired determinism is" ++
-                determinism_to_string(Desired) ++ ","),
-            words("while actual determinism is" ++
-                determinism_to_string(Actual) ++ "."),
-            nl],
-        add_to_spec_at_end(Pieces, !CurSpec)
+            words("desired determinism is"),
+            fixed(determinism_to_string(Desired)), suffix(","), nl,
+            words("while actual determinism is"),
+            fixed(determinism_to_string(Actual)), suffix("."), nl]
     ),
-    inst_preserving_append(InitSpecs, [!.CurSpec], AllSpecs),
-    inst_preserving_append(!.Specs, AllSpecs, !:Specs).
+    Msgs = [simple_msg(Context, [always(StartingPieces ++ Pieces)])].
 
     % det_diagnose_conj is used for both normal [sequential] conjunction
     % and parallel conjunction.
     %
 :- pred det_diagnose_conj(list(hlds_goal)::in, determinism::in,
-    list(switch_context)::in, det_info::in, bool::out,
-    list(error_msg_spec)::in, list(error_msg_spec)::out) is det.
+    list(switch_context)::in, det_info::in, list(error_msg)::out) is det.
 
-det_diagnose_conj([], _Desired, _SwitchContext, _DetInfo, no, !Specs).
-det_diagnose_conj([Goal | Goals], Desired, SwitchContext, DetInfo,
-        Diagnosed, !Specs) :-
-    det_diagnose_goal(Goal, Desired, SwitchContext, DetInfo, Diagnosed1,
-        !Specs),
-    det_diagnose_conj(Goals, Desired, SwitchContext, DetInfo, Diagnosed2,
-        !Specs),
-    bool.or(Diagnosed1, Diagnosed2, Diagnosed).
+det_diagnose_conj([], _Desired, _SwitchContext, _DetInfo, []).
+det_diagnose_conj([Goal | Goals], Desired, SwitchContext, DetInfo, Msgs) :-
+    det_diagnose_goal(Goal, Desired, SwitchContext, DetInfo, Msgs1),
+    det_diagnose_conj(Goals, Desired, SwitchContext, DetInfo, Msgs2),
+    Msgs = Msgs1 ++ Msgs2.
 
 :- pred det_diagnose_disj(list(hlds_goal)::in,
     determinism::in, determinism::in, list(switch_context)::in,
-    det_info::in, int::in, int::out, bool::out,
-    list(error_msg_spec)::in, list(error_msg_spec)::out) is det.
+    det_info::in, int::in, int::out, list(error_msg)::out) is det.
 
 det_diagnose_disj([], _Desired, _Actual, _SwitchContext, _DetInfo,
-        !ClausesWithSoln, no, !Specs).
+        !ClausesWithSoln, []).
 det_diagnose_disj([Goal | Goals], Desired, Actual, SwitchContext, DetInfo,
-        !ClausesWithSoln, Diagnosed, !Specs) :-
+        !ClausesWithSoln, Msgs) :-
     determinism_components(Actual, ActualCanFail, _),
     determinism_components(Desired, DesiredCanFail, DesiredSolns),
     (
         DesiredCanFail = cannot_fail,
         ActualCanFail = can_fail
     ->
-        % if the disjunction was declared to never fail,
-        % but we inferred that it might fail, then we
-        % want to print an error message for every disjunct
-        % that might fail
+        % If the disjunction was declared to never fail, but we inferred that
+        % it might fail, then we want to print an error message for every
+        % disjunct that might fail.
         ClauseCanFail = cannot_fail
     ;
-        % otherwise, either the disjunction is allowed to
-        % fail, or there is at least one disjunct that we
-        % inferred won't fail, so we don't want any error
-        % messages for the disjuncts that might fail
+        % Otherwise, either the disjunction is allowed to fail, or there is
+        % at least one disjunct that we inferred won't fail, so we don't want
+        % any error messages for the disjuncts that might fail
         ClauseCanFail = can_fail
     ),
     determinism_components(ClauseDesired, ClauseCanFail, DesiredSolns),
-    det_diagnose_goal(Goal, ClauseDesired, SwitchContext, DetInfo,
-        Diagnosed1, !Specs),
+    det_diagnose_goal(Goal, ClauseDesired, SwitchContext, DetInfo, Msgs1),
     (
         Goal = _ - GoalInfo,
         goal_info_get_determinism(GoalInfo, GoalDetism),
@@ -835,22 +806,19 @@
         !:ClausesWithSoln = !.ClausesWithSoln + 1
     ),
     det_diagnose_disj(Goals, Desired, Actual, SwitchContext, DetInfo,
-        !ClausesWithSoln, Diagnosed2, !Specs),
-    bool.or(Diagnosed1, Diagnosed2, Diagnosed).
+        !ClausesWithSoln, Msgs2),
+    Msgs = Msgs1 ++ Msgs2.
 
 :- pred det_diagnose_switch(prog_var::in, list(case)::in, determinism::in,
-    list(switch_context)::in, det_info::in, bool::out,
-    list(error_msg_spec)::in, list(error_msg_spec)::out) is det.
+    list(switch_context)::in, det_info::in, list(error_msg)::out) is det.
 
-det_diagnose_switch(_Var, [], _Desired, _SwitchContext, _DetInfo, no, !Specs).
+det_diagnose_switch(_Var, [], _Desired, _SwitchContext, _DetInfo, []).
 det_diagnose_switch(Var, [case(ConsId, Goal) | Cases], Desired,
-        SwitchContext0, DetInfo, Diagnosed, !Specs) :-
+        SwitchContext0, DetInfo, Msgs) :-
     SwitchContext1 = [switch_context(Var, ConsId) | SwitchContext0],
-    det_diagnose_goal(Goal, Desired, SwitchContext1, DetInfo, Diagnosed1,
-        !Specs),
-    det_diagnose_switch(Var, Cases, Desired, SwitchContext0, DetInfo,
-        Diagnosed2, !Specs),
-    bool.or(Diagnosed1, Diagnosed2, Diagnosed).
+    det_diagnose_goal(Goal, Desired, SwitchContext1, DetInfo, Msgs1),
+    det_diagnose_switch(Var, Cases, Desired, SwitchContext0, DetInfo, Msgs2),
+    Msgs = Msgs1 ++ Msgs2.
 
 %-----------------------------------------------------------------------------%
 
@@ -886,39 +854,36 @@
         PiecesHead = [fixed(ConsIdStr ++ ",")]
     ),
     cons_id_list_to_pieces(ConsIds, PiecesTail),
-    list.append(PiecesHead, PiecesTail, Pieces).
+    Pieces = PiecesHead ++ PiecesTail.
 
 %-----------------------------------------------------------------------------%
 
 :- type switch_context
     --->    switch_context(prog_var, cons_id).
 
-:- pred det_diagnose_switch_context(prog_context::in,
-    list(switch_context)::in, det_info::in,
-    list(error_msg_spec)::in, list(error_msg_spec)::out) is det.
-
-det_diagnose_switch_context(_Context, [], _, !Specs).
-det_diagnose_switch_context(Context, [SwitchContext | SwitchContexts],
-        DetInfo, !Specs) :-
+:- pred det_diagnose_switch_context(list(switch_context)::in, det_info::in,
+    list(format_component)::out) is det.
+
+det_diagnose_switch_context([], _, []).
+det_diagnose_switch_context([SwitchContext | SwitchContexts], DetInfo,
+        HeadPieces ++ TailPieces) :-
     det_get_proc_info(DetInfo, ProcInfo),
     proc_info_get_varset(ProcInfo, VarSet),
     SwitchContext = switch_context(Var, ConsId),
     ConsIdStr = cons_id_to_string(ConsId),
     VarStr = mercury_var_to_string(Var, VarSet, no),
-    Pieces = [words("Inside the case"), fixed(ConsIdStr),
+    HeadPieces = [words("Inside the case"), fixed(ConsIdStr),
         words("of the switch on"), fixed(VarStr), words(":")],
-    Spec = error_msg_spec(no, Context, 0, Pieces),
-    inst_preserving_append(!.Specs, [Spec], !:Specs),
-    det_diagnose_switch_context(Context, SwitchContexts, DetInfo, !Specs).
+    det_diagnose_switch_context(SwitchContexts, DetInfo, TailPieces).
 
 %-----------------------------------------------------------------------------%
 
 :- pred det_report_call_context(prog_context::in,
     maybe(call_unify_context)::in, det_info::in, pred_id::in, proc_id::in,
-    list(error_msg_spec)::out, error_msg_spec::out) is det.
+    list(error_msg)::out, list(format_component)::out) is det.
 
 det_report_call_context(Context, CallUnifyContext, DetInfo, PredId, ProcId,
-        InitSpecs, Spec) :-
+        InitMsgs, StartingPieces) :-
     det_info_get_module_info(DetInfo, ModuleInfo),
     module_info_pred_info(ModuleInfo, PredId, PredInfo),
     pred_info_get_origin(PredInfo, Origin),
@@ -930,21 +895,19 @@
     % in a function call inside some unification.)
 
     ( Origin = origin_special_pred(spec_pred_unify - _) ->
+        InitMsgs = [],
         (
             CallUnifyContext = yes(call_unify_context(LHS, RHS, UC)),
             First = yes,
             Last = yes,
             det_report_unify_context(First, Last, Context, UC, DetInfo,
-                LHS, RHS, Spec),
-            InitSpecs = []
+                LHS, RHS, StartingPieces)
         ;
             % This shouldn't happen; every call to a compiler generated
             % type-specific unification predicate should have a unify_context.
             CallUnifyContext = no,
-            Pieces = [words("Some weird unification"
-                ++ "(or explicit call to a type-specific unify predicate?)")],
-            Spec = error_msg_spec(no, Context, 0, Pieces),
-            InitSpecs = []
+            StartingPieces = [words("Some weird unification"
+                ++ "(or explicit call to a type-specific unify predicate?)")]
         )
     ;
         (
@@ -952,12 +915,13 @@
             First = yes,
             Last = no,
             det_report_unify_context(First, Last, Context, UC, DetInfo,
-                LHS, RHS, UnifySpec0),
-            add_to_spec_at_end([suffix(":")], UnifySpec0, UnifySpec),
-            InitSpecs = [UnifySpec]
+                LHS, RHS, UnifyPieces0),
+            UnifyPieces = UnifyPieces0 ++ [suffix(":")],
+            UnifyMsg = simple_msg(Context, [always(UnifyPieces)]),
+            InitMsgs = [UnifyMsg]
         ;
             CallUnifyContext = no,
-            InitSpecs = []
+            InitMsgs = []
         ),
         pred_info_get_procedures(PredInfo, ProcTable),
         map.lookup(ProcTable, ProcId, ProcInfo),
@@ -965,13 +929,12 @@
         proc_info_get_inst_varset(ProcInfo, InstVarSet),
         PredPieces = describe_one_pred_name_mode(ModuleInfo,
             should_module_qualify, PredId, InstVarSet, ArgModes),
-        CallPieces = [words("call to") | PredPieces],
-        Spec = error_msg_spec(no, Context, 0, CallPieces)
+        StartingPieces = [words("call to") | PredPieces]
     ).
 
 %-----------------------------------------------------------------------------%
 
-    % det_report_unify_context prints out information about the context of an
+    % det_report_unify_context returns information about the context of an
     % error, i.e. where the error occurred.
     %
     % The first two arguments are boolean flags that specify whether this is
@@ -981,11 +944,11 @@
     %
 :- pred det_report_unify_context(bool::in, bool::in, prog_context::in,
     unify_context::in, det_info::in, prog_var::in, unify_rhs::in,
-    error_msg_spec::out) is det.
+    list(format_component)::out) is det.
 
-det_report_unify_context(!.First, Last, Context, UnifyContext, DetInfo,
-        LHS, RHS, Spec) :-
-    unify_context_to_pieces(!First, UnifyContext, [], UnifyContextPieces),
+det_report_unify_context(!.First, Last, _Context, UnifyContext, DetInfo,
+        LHS, RHS, AllPieces) :-
+    unify_context_first_to_pieces(!First, UnifyContext, [], UnifyContextPieces),
     det_get_proc_info(DetInfo, ProcInfo),
     proc_info_get_varset(ProcInfo, VarSet),
     det_info_get_module_info(DetInfo, ModuleInfo),
@@ -1027,8 +990,7 @@
             words(add_quotes(
                 unify_rhs_to_string(RHS, ModuleInfo, VarSet, no)))]
     ),
-    AllPieces = UnifyContextPieces ++ Pieces,
-    Spec = error_msg_spec(no, Context, 0, AllPieces).
+    AllPieces = UnifyContextPieces ++ Pieces.
 
 %-----------------------------------------------------------------------------%
 
@@ -1062,272 +1024,167 @@
         )
     ).
 
-det_report_msgs(ContextMsgs0, ModuleInfo, WarnCnt, ErrCnt, !IO) :-
-    globals.io_lookup_bool_option(warn_simple_code, WarnSimple, !IO),
-    globals.io_lookup_bool_option(warn_duplicate_calls, WarnCalls, !IO),
-    globals.io_lookup_bool_option(warn_unknown_format_calls,
-        WarnUnknownFormat, !IO),
-    globals.io_lookup_bool_option(warn_known_bad_format_calls,
-        WarnKnownBadFormat, !IO),
+det_report_msgs(ContextMsgs, ModuleInfo, WarnCnt, ErrCnt, !IO) :-
+    Specs0 = list.map(det_report_to_error_spec(ModuleInfo), ContextMsgs),
         % Programmers prefer reading messages in order of context.
-    list.sort(ContextMsgs0, ContextMsgs),
-    det_report_msgs_2(ContextMsgs, WarnSimple, WarnCalls,
-        WarnUnknownFormat, WarnKnownBadFormat, ModuleInfo,
-        0, WarnCnt, 0, ErrCnt, !IO).
+    sort_error_specs(Specs0, Specs),
+    write_error_specs(Specs, 0, WarnCnt, 0, ErrCnt, !IO).
 
-:- pred det_report_msgs_2(list(context_det_msg)::in, bool::in, bool::in,
-    bool::in, bool::in, module_info::in, int::in, int::out, int::in, int::out,
-    io::di, io::uo) is det.
+:- func det_report_to_error_spec(module_info, context_det_msg) = error_spec.
 
-det_report_msgs_2([], _, _, _, _, _ModuleInfo, !WarnCnt, !ErrCnt, !IO).
-det_report_msgs_2([ContextMsg | ContextMsgs], WarnSimple, WarnCalls,
-        WarnUnknownFormat, WarnKnownBadFormat, ModuleInfo, !WarnCnt,
-        !ErrCnt, !IO) :-
-    ContextMsg = context_det_msg(Context, Msg),
-    det_msg_get_type(Msg, MsgType),
+det_report_to_error_spec(ModuleInfo, ContextDetMsg) = Spec :-
+    ContextDetMsg = context_det_msg(Context, DetMsg),
     (
-        WarnSimple = no,
-        MsgType = simple_code_warning
-    ->
-        true
-    ;
-        WarnCalls = no,
-        MsgType = call_warning
-    ->
-        true
-    ;
-        WarnUnknownFormat = no,
-        MsgType = format_unknown
-    ->
-        true
-    ;
-        WarnKnownBadFormat = no,
-        MsgType = format_known_bad
-    ->
-        true
-    ;
-        det_report_msg(Msg, Context, ModuleInfo, !IO),
         (
-            ( MsgType = simple_code_warning
-            ; MsgType = call_warning
-            ; MsgType = format_unknown
-            ; MsgType = format_known_bad
-            ),
-            !:WarnCnt = !.WarnCnt + 1
-        ;
-            MsgType = det_error,
-            !:ErrCnt = !.ErrCnt + 1
-        )
-    ),
-    det_report_msgs_2(ContextMsgs, WarnSimple, WarnCalls,
-        WarnUnknownFormat, WarnKnownBadFormat, ModuleInfo,
-        !WarnCnt, !ErrCnt, !IO).
-
-:- pred det_msg_get_type(det_msg::in, det_msg_type::out) is det.
-
-det_msg_get_type(multidet_disj(_), simple_code_warning).
-det_msg_get_type(det_disj(_), simple_code_warning).
-det_msg_get_type(semidet_disj(_), simple_code_warning).
-det_msg_get_type(zero_soln_disj(_), simple_code_warning).
-det_msg_get_type(zero_soln_disjunct, simple_code_warning).
-det_msg_get_type(ite_cond_cannot_fail, simple_code_warning).
-det_msg_get_type(ite_cond_cannot_succeed, simple_code_warning).
-det_msg_get_type(negated_goal_cannot_fail, simple_code_warning).
-det_msg_get_type(negated_goal_cannot_succeed, simple_code_warning).
-det_msg_get_type(goal_cannot_succeed, simple_code_warning).
-det_msg_get_type(det_goal_has_no_outputs, simple_code_warning).
-    % XXX warn_obsolete isn't really a simple code warning.
-    % We should add a separate warning type for this.
-det_msg_get_type(warn_call_to_obsolete(_), simple_code_warning).
-det_msg_get_type(warn_infinite_recursion, simple_code_warning).
-det_msg_get_type(duplicate_call(_, _), call_warning).
-det_msg_get_type(unknown_format_string(_, _), format_unknown).
-det_msg_get_type(unknown_format_values(_, _), format_unknown).
-det_msg_get_type(bad_format(_, _, _), format_known_bad).
-det_msg_get_type(cc_unify_can_fail(_, _, _, _, _), det_error).
-det_msg_get_type(cc_unify_in_wrong_context(_, _, _, _, _, _), det_error).
-det_msg_get_type(cc_pred_in_wrong_context(_, _, _, _, _, _), det_error).
-det_msg_get_type(higher_order_cc_pred_in_wrong_context(_, _, _, _), det_error).
-det_msg_get_type(error_in_lambda(_, _, _, _, _, _), det_error).
-det_msg_get_type(par_conj_not_det(_, _, _, _, _), det_error).
-det_msg_get_type(pragma_c_code_without_det_decl(_, _), det_error).
-det_msg_get_type(has_io_state_but_not_det(_, _), det_error).
-det_msg_get_type(will_not_throw_with_erroneous(_, _), det_error).
-det_msg_get_type(export_model_non_proc(_, _, _), det_error).
-det_msg_get_type(nested_promise_eqv_solution_sets(_), simple_code_warning).
-det_msg_get_type(arbitrary_without_promise, det_error).
-det_msg_get_type(arbitrary_promise_overlap(_, _, _), det_error).
-det_msg_get_type(promise_solutions_missing_vars(_, _, _), det_error).
-det_msg_get_type(promise_solutions_extra_vars(_, _, _), det_error).
-det_msg_get_type(trace_goal_not_det(_), det_error).
-
-det_msg_is_any_mode_msg(multidet_disj(_), all_modes).
-det_msg_is_any_mode_msg(det_disj(_), all_modes).
-det_msg_is_any_mode_msg(semidet_disj(_), all_modes).
-det_msg_is_any_mode_msg(zero_soln_disj(_), all_modes).
-det_msg_is_any_mode_msg(zero_soln_disjunct, all_modes).
-det_msg_is_any_mode_msg(ite_cond_cannot_fail, all_modes).
-det_msg_is_any_mode_msg(ite_cond_cannot_succeed, all_modes).
-det_msg_is_any_mode_msg(negated_goal_cannot_fail, all_modes).
-det_msg_is_any_mode_msg(negated_goal_cannot_succeed, all_modes).
-det_msg_is_any_mode_msg(goal_cannot_succeed, all_modes).
-det_msg_is_any_mode_msg(det_goal_has_no_outputs, all_modes).
-det_msg_is_any_mode_msg(warn_call_to_obsolete(_), all_modes).
-det_msg_is_any_mode_msg(warn_infinite_recursion, any_mode).
-det_msg_is_any_mode_msg(duplicate_call(_, _), any_mode).
-det_msg_is_any_mode_msg(unknown_format_string(_, _), any_mode).
-det_msg_is_any_mode_msg(unknown_format_values(_, _), any_mode).
-det_msg_is_any_mode_msg(bad_format(_, _, _), any_mode).
-det_msg_is_any_mode_msg(cc_unify_can_fail(_, _, _, _, _), any_mode).
-det_msg_is_any_mode_msg(cc_unify_in_wrong_context(_, _, _, _, _, _), any_mode).
-det_msg_is_any_mode_msg(cc_pred_in_wrong_context(_, _, _, _, _, _), any_mode).
-det_msg_is_any_mode_msg(higher_order_cc_pred_in_wrong_context(_, _, _, _),
-    any_mode).
-det_msg_is_any_mode_msg(error_in_lambda(_, _, _, _, _, _), any_mode).
-det_msg_is_any_mode_msg(par_conj_not_det(_, _, _, _, _), any_mode).
-det_msg_is_any_mode_msg(pragma_c_code_without_det_decl(_, _), any_mode).
-det_msg_is_any_mode_msg(has_io_state_but_not_det(_, _), any_mode).
-det_msg_is_any_mode_msg(will_not_throw_with_erroneous(_, _), any_mode).
-det_msg_is_any_mode_msg(export_model_non_proc(_, _, _), any_mode).
-det_msg_is_any_mode_msg(nested_promise_eqv_solution_sets(_), any_mode).
-det_msg_is_any_mode_msg(arbitrary_without_promise, any_mode).
-det_msg_is_any_mode_msg(arbitrary_promise_overlap(_, _, _), any_mode).
-det_msg_is_any_mode_msg(promise_solutions_missing_vars(_, _, _), any_mode).
-det_msg_is_any_mode_msg(promise_solutions_extra_vars(_, _, _), any_mode).
-det_msg_is_any_mode_msg(trace_goal_not_det(_), any_mode).
-
-:- pred det_report_msg(det_msg::in, prog_context::in, module_info::in,
-    io::di, io::uo) is det.
-
-det_report_msg(multidet_disj(DisjunctContexts), Context, _, !IO) :-
+            DetMsg = multidet_disj(DisjunctContexts),
     Pieces = [words("Warning: the disjunction with arms on lines"),
         words(det_report_context_lines(DisjunctContexts)),
-        words("has no outputs, but can succeed more than once.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(det_disj(DisjunctContexts), Context, _, !IO) :-
+                words("has no outputs, but can succeed more than once.")]
+        ;
+            DetMsg = det_disj(DisjunctContexts),
     Pieces = [words("Warning: the disjunction with arms on lines"),
         words(det_report_context_lines(DisjunctContexts)),
-        words("will succeed exactly once.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(semidet_disj(DisjunctContexts), Context, _, !IO) :-
+                words("will succeed exactly once.")]
+        ;
+            DetMsg = semidet_disj(DisjunctContexts),
     Pieces = [words("Warning: the disjunction with arms on lines"),
         words(det_report_context_lines(DisjunctContexts)),
-        words("is semidet, yet it has an output.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(zero_soln_disj(DisjunctContexts), Context, _, !IO) :-
+                words("is semidet, yet it has an output.")]
+        ;
+            DetMsg = zero_soln_disj(DisjunctContexts),
     Pieces = [words("Warning: the disjunction with arms on lines"),
         words(det_report_context_lines(DisjunctContexts)),
-        words("cannot succeed.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(zero_soln_disjunct, Context, _, !IO) :-
+                words("cannot succeed.")]
+        ;
+            DetMsg = zero_soln_disjunct,
     Pieces = [words("Warning: this disjunct"),
-        words("will never have any solutions.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(ite_cond_cannot_fail, Context, _, !IO) :-
+                words("will never have any solutions.")]
+        ;
+            DetMsg = ite_cond_cannot_fail,
     Pieces = [words("Warning: the condition of this if-then-else"),
-        words("cannot fail.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(ite_cond_cannot_succeed, Context, _, !IO) :-
+                words("cannot fail.")]
+        ;
+            DetMsg = ite_cond_cannot_succeed,
     Pieces = [words("Warning: the condition of this if-then-else"),
-        words("cannot succeed.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(negated_goal_cannot_fail, Context, _, !IO) :-
-    Pieces = [words("Warning: the negated goal cannot fail.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(negated_goal_cannot_succeed, Context, _, !IO) :-
-    Pieces = [words("Warning: the negated goal cannot succeed.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(goal_cannot_succeed, Context, _, !IO) :-
-    Pieces0 = [words("Warning: this goal cannot succeed.")],
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
+                words("cannot succeed.")]
+        ;
+            DetMsg = negated_goal_cannot_fail,
+            Pieces = [words("Warning: the negated goal cannot fail.")]
+        ;
+            DetMsg = negated_goal_cannot_succeed,
+            Pieces = [words("Warning: the negated goal cannot succeed.")]
+        ;
+            DetMsg = warn_call_to_obsolete(PredId),
+            % XXX warn_obsolete isn't really a simple code warning.
+            % We should add a separate warning type for this.
+            PredPieces = describe_one_pred_name(ModuleInfo,
+                should_module_qualify, PredId),
+            Pieces = [words("Warning: call to obsolete")] ++ PredPieces
+                ++ [suffix(".")]
+        ),
+        Spec = error_spec(severity_warning, phase_detism_check,
+            [simple_msg(Context,
+                [option_is_set(warn_simple_code, yes, [always(Pieces)])])])
+    ;
     (
-        VerboseErrors = yes,
-        Pieces1 = [words("The compiler will optimize away this goal,"),
+            DetMsg = goal_cannot_succeed,
+            MainPieces = [words("Warning: this goal cannot succeed.")],
+            VerbosePieces =
+                [words("The compiler will optimize away this goal,"),
             words("replacing it with `fail'."),
-            words("To disable this optimization, use "),
-            words("the `--fully-strict' option.")],
-        Pieces = Pieces0 ++ Pieces1
-    ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO),
-        Pieces = Pieces0
-    ),
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(det_goal_has_no_outputs, Context, _, !IO) :-
-    Pieces0 = [words("Warning: det goal has no outputs.")],
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
-        Pieces1 = [words("The compiler will optimize away this goal,"),
+                words("To disable this optimization, use"),
+                words("the `--fully-strict' option.")]
+        ;
+            DetMsg = det_goal_has_no_outputs,
+            MainPieces = [words("Warning: det goal has no outputs.")],
+            VerbosePieces =
+                [words("The compiler will optimize away this goal,"),
             words("replacing it with `true'."),
-            words("To disable this optimization, use "),
-            words("the `--fully-strict' option.")],
-        Pieces = Pieces0 ++ Pieces1
-    ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO),
-        Pieces = Pieces0
-    ),
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(warn_call_to_obsolete(PredId), Context, ModuleInfo, !IO) :-
-    PredPieces = describe_one_pred_name(ModuleInfo, should_module_qualify,
-        PredId),
-    Pieces = [words("Warning: call to obsolete")] ++ PredPieces
-        ++ [suffix(".")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(warn_infinite_recursion, Context, _ModuleInfo, !IO) :-
-    % it would be better if we supplied more information than just
+                words("To disable this optimization, use"),
+                words("the `--fully-strict' option.")]
+        ;
+            DetMsg = warn_infinite_recursion,
+            % It would be better if we supplied more information than just
     % the line number, e.g. we should print the name of the containing
     % predicate.
-    Pieces0 = [words("Warning: recursive call will lead"),
+            MainPieces = [words("Warning: recursive call will lead"),
         words("to infinite recursion.")],
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
-        Pieces1 = [words("If this recursive call is executed,"),
+            VerbosePieces = [words("If this recursive call is executed,"),
             words("the procedure will call itself"),
             words("with exactly the same input arguments,"),
-            words("leading to infinite recursion.")],
-        Pieces = Pieces0 ++ Pieces1
+                words("leading to infinite recursion.")]
+        ),
+        Spec = error_spec(severity_warning, phase_detism_check,
+            [simple_msg(Context,
+                [option_is_set(warn_simple_code, yes,
+                    [always(MainPieces), verbose_only(VerbosePieces)])])])
     ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO),
-        Pieces = Pieces0
-    ),
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(duplicate_call(SeenCall, PrevContext), Context, ModuleInfo,
-        !IO) :-
+        DetMsg = duplicate_call(SeenCall, PrevContext),
     CallPieces = det_report_seen_call_id(ModuleInfo, SeenCall),
-    CurPieces = [words("Warning: redundant") | CallPieces] ++ [suffix(".")],
-    PrevPieces = [words("Here is the previous") | CallPieces] ++ [suffix(".")],
-    write_error_pieces(Context, 0, CurPieces, !IO),
-    write_error_pieces(PrevContext, 0, PrevPieces, !IO).
-det_report_msg(unknown_format_string(SymName, Arity), Context, _, !IO) :-
+        CurPieces = [words("Warning: redundant") | CallPieces] 
+            ++ [suffix(".")],
+        PrevPieces = [words("Here is the previous") | CallPieces]
+            ++ [suffix(".")],
+        Spec = error_spec(severity_warning, phase_detism_check,
+            [simple_msg(Context,
+                [option_is_set(warn_duplicate_calls, yes,
+                    [always(CurPieces)])]),
+            error_msg(yes(PrevContext), yes, 0,
+                [option_is_set(warn_duplicate_calls, yes,
+                    [always(PrevPieces)])])
+            ])
+    ;
+        DetMsg = nested_promise_eqv_solution_sets(OuterContext),
+        Pieces = [words("Error: "),
+            words("`promise_equivalent_solution_sets' scope"),
+            words("is nested inside another.")],
+        OuterPieces = [words("This is the outer"),
+            words("`promise_equivalent_solution_sets' scope.")],
+        Spec = error_spec(severity_warning, phase_detism_check,
+            [simple_msg(Context,
+                [option_is_set(warn_simple_code, yes, [always(Pieces)])]),
+            simple_msg(OuterContext,
+                [option_is_set(warn_simple_code, yes, [always(OuterPieces)])])
+            ])
+    ;
+        (
+            DetMsg = unknown_format_string(SymName, Arity),
     Pieces = [words("Unknown format string in call to"),
-        sym_name_and_arity(SymName / Arity), suffix(".")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(unknown_format_values(SymName, Arity), Context, _, !IO) :-
+                sym_name_and_arity(SymName / Arity), suffix(".")]
+        ;
+            DetMsg = unknown_format_values(SymName, Arity),
     Pieces = [words("Unknown format values in call to"),
-        sym_name_and_arity(SymName / Arity), suffix(".")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(bad_format(SymName, Arity, Msg), Context, _, !IO) :-
+                sym_name_and_arity(SymName / Arity), suffix(".")]
+        ),
+        Spec = error_spec(severity_warning, phase_detism_check,
+            [simple_msg(Context,
+                [option_is_set(warn_unknown_format_calls, yes,
+                    [always(Pieces)])])])
+    ;
+        DetMsg = bad_format(SymName, Arity, Msg),
     Pieces = [words("Mismatched format and values in call to"),
         sym_name_and_arity(SymName / Arity), suffix(":"), nl, words(Msg)],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(cc_unify_can_fail(_GoalInfo, Var, Type, VarSet, GoalContext),
-        Context, _ModuleInfo, !IO) :-
+        Spec = error_spec(severity_warning, phase_detism_check,
+            [simple_msg(Context,
+                [option_is_set(warn_known_bad_format_calls, yes,
+                    [always(Pieces)])])])
+    ;
+        DetMsg = cc_unify_can_fail(_GoalInfo, Var, Type, VarSet, GoalContext),
     (
         GoalContext = ccuc_switch,
         VarStr = mercury_var_to_string(Var, VarSet, no),
-        Pieces0 = [words("In switch on variable `" ++ VarStr ++ "':"), nl]
+            Pieces0 = [words("In switch on variable"), quote(VarStr),
+                suffix(":"), nl]
     ;
         GoalContext = ccuc_unify(UnifyContext),
         hlds_out.unify_context_to_pieces(UnifyContext, [], Pieces0)
     ),
     ( type_to_ctor_and_args(Type, TypeCtor, _TypeArgs) ->
-        TypeCtorStr = hlds_out.type_ctor_to_string(TypeCtor)
+            TypeCtor = type_ctor(TypeCtorName, TypeCtorArity),
+            TypeCtorSymName = TypeCtorName / TypeCtorArity
     ;
-        unexpected(this_file, "det_report_msg: type_to_ctor_and_args failed")
+            unexpected(this_file, "det_report_to_error_spec: " ++
+                "cc_unify_can_fail: type_to_ctor_and_args failed")
     ),
     (
         Pieces0 = [],
@@ -1338,13 +1195,8 @@
     ),
     Pieces1 = [words(ErrorMsg),
         words("unification for non-canonical type"),
-        words("`" ++ TypeCtorStr ++ "'"),
+            sym_name_and_arity(TypeCtorSymName),
         words("is not guaranteed to succeed.")],
-    Pieces = Pieces0 ++ Pieces1,
-    write_error_pieces(Context, 0, Pieces, !IO),
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
         VerbosePieces = [words("Since the type has a user-defined"),
             words("equality predicate, I must presume that"),
             words("there is more than one possible concrete"),
@@ -1357,25 +1209,25 @@
             words("representations, but I'm not going to do that"),
             words("implicitly. (If that's really what you want,"),
             words("you must do it explicitly.)")],
-        write_error_pieces_not_first_line(Context, 0, VerbosePieces, !IO)
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context,
+                [always(Pieces0 ++ Pieces1), verbose_only(VerbosePieces)])])
     ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO)
-    ).
-det_report_msg(cc_unify_in_wrong_context(_GoalInfo, Var, Type, VarSet,
-        GoalContext, FailingContexts), Context, ModuleInfo, !IO) :-
+        DetMsg = cc_unify_in_wrong_context(_GoalInfo, Var, Type, VarSet,
+            GoalContext, FailingContexts),
     (
         GoalContext = ccuc_switch,
         VarStr = mercury_var_to_string(Var, VarSet, no),
         Pieces0 = [words("In switch on variable `" ++ VarStr ++ "':"), nl]
     ;
         GoalContext = ccuc_unify(UnifyContext),
-        hlds_out.unify_context_to_pieces(yes, _, UnifyContext, [], Pieces0)
+            unify_context_first_to_pieces(yes, _, UnifyContext, [], Pieces0)
     ),
     ( type_to_ctor_and_args(Type, TypeCtor, _TypeArgs) ->
         TypeCtorStr = hlds_out.type_ctor_to_string(TypeCtor)
     ;
-        unexpected(this_file, "det_report_msg: type_to_ctor_and_args failed")
+            unexpected(this_file, "det_report_msg: " ++
+                "cc_unify_in_wrong_context: type_to_ctor_and_args failed")
     ),
     (
         Pieces0 = [],
@@ -1388,13 +1240,6 @@
         words("unification for non-canonical type"),
         words("`" ++ TypeCtorStr ++ "'"),
         words("occurs in a context which requires all solutions."), nl],
-    FirstPieces = Pieces0 ++ Pieces1,
-    FirstSpec = error_msg_spec(yes, Context, 0, FirstPieces),
-    LaterSpecs = failing_contexts_description(ModuleInfo, VarSet,
-        FailingContexts),
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
         VerbosePieces = [words("Since the type has a user-defined"),
             words("equality predicate, I must presume that"),
             words("there is more than one possible concrete"),
@@ -1407,55 +1252,57 @@
             words("representations, but I'm not going to do that"),
             words("implicitly. (If that's really what you want,"),
             words("you must do it explicitly.)")],
-        VerboseSpec = error_msg_spec(no, Context, 0, VerbosePieces),
-        write_error_specs([FirstSpec, VerboseSpec | LaterSpecs], !IO)
+        ContextMsgs = failing_contexts_description(ModuleInfo, VarSet,
+            FailingContexts),
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context,
+                [always(Pieces0 ++ Pieces1), verbose_only(VerbosePieces)])]
+            ++ ContextMsgs)
     ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO),
-        write_error_specs([FirstSpec | LaterSpecs], !IO)
-    ).
-det_report_msg(cc_pred_in_wrong_context(_GoalInfo, Detism, PredId,
-        _ModeId, VarSet, FailingContexts), Context, ModuleInfo, !IO) :-
-    PredPieces = describe_one_pred_name(ModuleInfo,
-        should_not_module_qualify, PredId),
-    DetStr = mercury_det_to_string(Detism),
+        DetMsg = cc_pred_in_wrong_context(_GoalInfo, Detism, PredId,
+            _ModeId, VarSet, FailingContexts),
+        PredPieces = describe_one_pred_name(ModuleInfo, should_module_qualify,
+            PredId),
     FirstPieces = [words("Error: call to")] ++ PredPieces ++
-        [words("with determinism `" ++ DetStr ++ "'"),
+            [words("with determinism"), quote(mercury_det_to_string(Detism)),
         words("occurs in a context which requires all solutions."), nl],
-    FirstSpec = error_msg_spec(yes, Context, 0, FirstPieces),
-    LaterSpecs = failing_contexts_description(ModuleInfo, VarSet,
+        ContextMsgs = failing_contexts_description(ModuleInfo, VarSet,
         FailingContexts),
-    write_error_specs([FirstSpec | LaterSpecs], !IO).
-det_report_msg(higher_order_cc_pred_in_wrong_context(_GoalInfo, Detism,
-        VarSet, FailingContexts), Context, ModuleInfo, !IO) :-
-    DetStr = mercury_det_to_string(Detism),
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(FirstPieces)])] ++ ContextMsgs)
+    ;
+        DetMsg = higher_order_cc_pred_in_wrong_context(_GoalInfo, Detism,
+            VarSet, FailingContexts),
     FirstPieces = [words("Error: higher-order call to predicate with"),
-        words("determinism `" ++ DetStr ++ "'"),
+            words("determinism"), quote(mercury_det_to_string(Detism)),
         words("occurs in a context which requires all solutions."), nl],
-    FirstSpec = error_msg_spec(yes, Context, 0, FirstPieces),
-    LaterSpecs = failing_contexts_description(ModuleInfo, VarSet,
+        ContextMsgs = failing_contexts_description(ModuleInfo, VarSet,
         FailingContexts),
-    write_error_specs([FirstSpec | LaterSpecs], !IO).
-det_report_msg(error_in_lambda(DeclaredDetism, InferredDetism,
-        Goal, _GoalInfo, PredId, ProcId), Context, ModuleInfo, !IO) :-
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(FirstPieces)])] ++ ContextMsgs)
+    ;
+        DetMsg = error_in_lambda(DeclaredDetism, InferredDetism,
+            Goal, _GoalInfo, PredId, ProcId),
     PredPieces = describe_one_proc_name_mode(ModuleInfo,
         should_not_module_qualify, proc(PredId, ProcId)),
     Pieces =
         [words("In")] ++ PredPieces ++ [suffix(":"), nl,
         words("Determinism error in lambda expression."), nl,
-        words("Declared `" ++ determinism_to_string(DeclaredDetism)
-            ++ "', inferred `" ++ determinism_to_string(InferredDetism)
-            ++ "'.")],
-    ReportSpec = error_msg_spec(no, Context, 0, Pieces),
-    globals.io_get_globals(Globals, !IO),
+            words("Declared"),
+            quote(determinism_to_string(DeclaredDetism)), suffix(","),
+            words("inferred"),
+            quote(determinism_to_string(InferredDetism)), suffix("'.")],
+        module_info_get_globals(ModuleInfo, Globals),
     module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo),
     proc_info_get_vartypes(ProcInfo, VarTypes),
     det_info_init(ModuleInfo, VarTypes, PredId, ProcId, Globals, DetInfo),
-    det_diagnose_goal(Goal, DeclaredDetism, [], DetInfo, _,
-        [ReportSpec], Specs),
-    write_error_specs(Specs, !IO).
-det_report_msg(par_conj_not_det(InferredDetism, PredId, ProcId,
-        _GoalInfo, Goals), Context, ModuleInfo, !IO) :-
+        det_diagnose_goal(Goal, DeclaredDetism, [], DetInfo, GoalMsgs0),
+        sort_error_msgs(GoalMsgs0, GoalMsgs),
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(Pieces)])] ++ GoalMsgs)
+    ;
+        DetMsg = par_conj_not_det(InferredDetism, PredId, ProcId,
+            _GoalInfo, Goals),
     determinism_components(InferredDetism, CanFail, MaxSoln),
     ( CanFail \= cannot_fail ->
         First = "Error: parallel conjunct may fail."
@@ -1465,43 +1312,41 @@
         unexpected(this_file,
             "strange determinism error for parallel conjunction")
     ),
-    Rest = "The current implementation supports only single-solution "
-        ++ "non-failing parallel conjunctions.",
-    ReportSpec = error_msg_spec(no, Context, 0, [words(First), words(Rest)]),
-    globals.io_get_globals(Globals, !IO),
+        Rest = "The current implementation supports only "
+            ++ "single-solution non-failing parallel conjunctions.",
+        Pieces = [words(First), words(Rest)],
+        module_info_get_globals(ModuleInfo, Globals),
     module_info_pred_proc_info(ModuleInfo, PredId, ProcId, _, ProcInfo),
     proc_info_get_vartypes(ProcInfo, VarTypes),
     det_info_init(ModuleInfo, VarTypes, PredId, ProcId, Globals, DetInfo),
-    det_diagnose_conj(Goals, detism_det, [], DetInfo, _, [ReportSpec], Specs),
-    write_error_specs(Specs, !IO).
-det_report_msg(pragma_c_code_without_det_decl(PredId, ProcId), Context,
-        ModuleInfo, !IO) :-
+        det_diagnose_conj(Goals, detism_det, [], DetInfo, GoalMsgs0),
+        sort_error_msgs(GoalMsgs0, GoalMsgs),
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(Pieces)])] ++ GoalMsgs)
+    ;
+        DetMsg = pragma_c_code_without_det_decl(PredId, ProcId),
     ProcPieces = describe_one_proc_name_mode(ModuleInfo,
         should_not_module_qualify, proc(PredId, ProcId)),
     Pieces = [words("In")] ++ ProcPieces ++ [suffix(":"), nl,
         words("error: `:- pragma c_code(...)' for a procedure"),
         words("without a determinism declaration.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(has_io_state_but_not_det(PredId, ProcId), Context, ModuleInfo,
-        !IO) :-
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(Pieces)])])
+    ;
+        DetMsg = has_io_state_but_not_det(PredId, ProcId),
     ProcPieces = describe_one_proc_name_mode(ModuleInfo,
         should_not_module_qualify, proc(PredId, ProcId)),
     Pieces = [words("In")] ++ ProcPieces ++ [suffix(":"), nl,
         words("error: invalid determinism for a predicate"),
         words("with I/O state arguments.")],
-    write_error_pieces(Context, 0, Pieces, !IO),
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
         VerbosePieces = [words("Valid determinisms are "),
             words("det, cc_multi and erroneous.")],
-        write_error_pieces_not_first_line(Context, 0, VerbosePieces, !IO)
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context,
+                [always(Pieces), verbose_only(VerbosePieces)])])
     ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO)
-    ).
-det_report_msg(will_not_throw_with_erroneous(PredId, ProcId), Context,
-        ModuleInfo, !IO) :-
+        (
+            DetMsg = will_not_throw_with_erroneous(PredId, ProcId),
     ProcPieces = describe_one_proc_name_mode(ModuleInfo,
         should_not_module_qualify, proc(PredId, ProcId)),
     Pieces = ProcPieces ++
@@ -1509,31 +1354,24 @@
         words("foreign clauses that have a"),
         fixed("`will_not_throw_exception' attribute."),
         words("This attribute cannot be applied"),
-        words("to erroneous procedures.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(export_model_non_proc(_PredId, _ProcId, Detism), Context,
-        _ModuleInfo, !IO) :-
+                words("to erroneous procedures.")]
+        ;
+            DetMsg = export_model_non_proc(_PredId, _ProcId, Detism),
     Pieces = [words("Error: "),
         fixed("`:- pragma export' declaration"),
         words("for a procedure that has a determinism of"),
-        fixed(hlds_out.determinism_to_string(Detism) ++ ".")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(nested_promise_eqv_solution_sets(OuterContext), Context,
-        _ModuleInfo, !IO) :-
-    Pieces = [words("Error: "),
-        words("`promise_equivalent_solution_sets' scope"),
-        words("is nested inside another.")],
-    write_error_pieces(Context, 0, Pieces, !IO),
-    Pieces2 = [words("This is the outer "),
-        words("`promise_equivalent_solution_sets' scope.")],
-    write_error_pieces_not_first_line(OuterContext, 0, Pieces2, !IO).
-det_report_msg(arbitrary_without_promise, Context, _ModuleInfo, !IO) :-
+                fixed(hlds_out.determinism_to_string(Detism) ++ ".")]
+        ;
+            DetMsg = arbitrary_without_promise,
     Pieces = [words("Error: "),
         words("this `arbitrary' scope is not nested inside"),
-        words("a `promise_equivalent_solution_sets' scope.")],
-    write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(arbitrary_promise_overlap(PromiseContext, VarSet, OverlapVars),
-        Context, _ModuleInfo, !IO) :-
+                words("a `promise_equivalent_solution_sets' scope.")]
+        ),
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(Pieces)])])
+    ;
+        DetMsg = arbitrary_promise_overlap(PromiseContext, VarSet,
+            OverlapVars),
     VarNames = list.map(lookup_var_name_in_varset(VarSet),
         set.to_sorted_list(OverlapVars)),
     (
@@ -1549,15 +1387,16 @@
     ),
     Pieces = [words("Error: "),
         words("this `arbitrary' scope and the"),
-        words("`promise_equivalent_solution_sets' scope it is nested inside"),
-        words("overlap on"), words(VarStr)]
+            words("`promise_equivalent_solution_sets' scope"),
+            words("it is nested inside overlap on"), words(VarStr)]
         ++ list_to_pieces(VarNames) ++ [suffix(".")],
-    write_error_pieces(Context, 0, Pieces, !IO),
-    Pieces2 = [words("This is the outer "),
+        PromisePieces = [words("This is the outer "),
         words("`promise_equivalent_solution_sets' scope.")],
-    write_error_pieces_not_first_line(PromiseContext, 0, Pieces2, !IO).
-det_report_msg(promise_solutions_missing_vars(Kind, VarSet, Vars), Context, _,
-        !IO) :-
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(Pieces)]),
+            simple_msg(PromiseContext, [always(PromisePieces)])])
+    ;
+        DetMsg = promise_solutions_missing_vars(Kind, VarSet, Vars),
     VarNames = list.map(lookup_var_name_in_varset(VarSet),
         set.to_sorted_list(Vars)),
     KindStr = promise_solutions_kind_str(Kind),
@@ -1575,16 +1414,17 @@
     Pieces = [words("Error: the"), words(add_quotes(KindStr)),
         words("goal binds"), words(ListStr)]
         ++ list_to_pieces(VarNames) ++ [suffix(".")],
-    error_util.write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(promise_solutions_extra_vars(Kind, VarSet, Vars), Context, _,
-        !IO) :-
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(Pieces)])])
+    ;
+        DetMsg = promise_solutions_extra_vars(Kind, VarSet, Vars),
     VarNames = list.map(lookup_var_name_in_varset(VarSet),
         set.to_sorted_list(Vars)),
     KindStr = promise_solutions_kind_str(Kind),
     (
         VarNames = [],
-        unexpected(this_file, "det_report_msg: " ++
-            "promise_solutions_extra_vars empty")
+            unexpected(this_file,
+                "det_report_msg: promise_solutions_extra_vars empty")
     ;
         VarNames = [_],
         ListStr = "an extra variable:"
@@ -1593,14 +1433,54 @@
         ListStr = "some extra variables:"
     ),
     Pieces = [words("Error: the"), words(add_quotes(KindStr)),
-        words("goal lists"), words(ListStr)]
-        ++ list_to_pieces(VarNames) ++ [suffix(".")],
-    error_util.write_error_pieces(Context, 0, Pieces, !IO).
-det_report_msg(trace_goal_not_det(Detism), Context, _, !IO) :-
+            words("goal lists"), words(ListStr)] ++
+            list_to_pieces(VarNames) ++ [suffix(".")],
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(Pieces)])])
+    ;
+        DetMsg = trace_goal_not_det(Detism),
     DetismStr = determinism_to_string(Detism),
     Pieces = [words("Error: trace goal has determinism"),
-        quote(DetismStr), suffix(","), words("should be det or cc_multi.")],
-    error_util.write_error_pieces(Context, 0, Pieces, !IO).
+            quote(DetismStr), suffix(","),
+            words("should be det or cc_multi.")],
+        Spec = error_spec(severity_error, phase_detism_check,
+            [simple_msg(Context, [always(Pieces)])])
+    ).
+
+det_msg_is_any_mode_msg(multidet_disj(_), all_modes).
+det_msg_is_any_mode_msg(det_disj(_), all_modes).
+det_msg_is_any_mode_msg(semidet_disj(_), all_modes).
+det_msg_is_any_mode_msg(zero_soln_disj(_), all_modes).
+det_msg_is_any_mode_msg(zero_soln_disjunct, all_modes).
+det_msg_is_any_mode_msg(ite_cond_cannot_fail, all_modes).
+det_msg_is_any_mode_msg(ite_cond_cannot_succeed, all_modes).
+det_msg_is_any_mode_msg(negated_goal_cannot_fail, all_modes).
+det_msg_is_any_mode_msg(negated_goal_cannot_succeed, all_modes).
+det_msg_is_any_mode_msg(goal_cannot_succeed, all_modes).
+det_msg_is_any_mode_msg(det_goal_has_no_outputs, all_modes).
+det_msg_is_any_mode_msg(warn_call_to_obsolete(_), all_modes).
+det_msg_is_any_mode_msg(warn_infinite_recursion, any_mode).
+det_msg_is_any_mode_msg(duplicate_call(_, _), any_mode).
+det_msg_is_any_mode_msg(unknown_format_string(_, _), any_mode).
+det_msg_is_any_mode_msg(unknown_format_values(_, _), any_mode).
+det_msg_is_any_mode_msg(bad_format(_, _, _), any_mode).
+det_msg_is_any_mode_msg(cc_unify_can_fail(_, _, _, _, _), any_mode).
+det_msg_is_any_mode_msg(cc_unify_in_wrong_context(_, _, _, _, _, _), any_mode).
+det_msg_is_any_mode_msg(cc_pred_in_wrong_context(_, _, _, _, _, _), any_mode).
+det_msg_is_any_mode_msg(higher_order_cc_pred_in_wrong_context(_, _, _, _),
+    any_mode).
+det_msg_is_any_mode_msg(error_in_lambda(_, _, _, _, _, _), any_mode).
+det_msg_is_any_mode_msg(par_conj_not_det(_, _, _, _, _), any_mode).
+det_msg_is_any_mode_msg(pragma_c_code_without_det_decl(_, _), any_mode).
+det_msg_is_any_mode_msg(has_io_state_but_not_det(_, _), any_mode).
+det_msg_is_any_mode_msg(will_not_throw_with_erroneous(_, _), any_mode).
+det_msg_is_any_mode_msg(export_model_non_proc(_, _, _), any_mode).
+det_msg_is_any_mode_msg(nested_promise_eqv_solution_sets(_), any_mode).
+det_msg_is_any_mode_msg(arbitrary_without_promise, any_mode).
+det_msg_is_any_mode_msg(arbitrary_promise_overlap(_, _, _), any_mode).
+det_msg_is_any_mode_msg(promise_solutions_missing_vars(_, _, _), any_mode).
+det_msg_is_any_mode_msg(promise_solutions_extra_vars(_, _, _), any_mode).
+det_msg_is_any_mode_msg(trace_goal_not_det(_), any_mode).
 
 :- func promise_solutions_kind_str(promise_solutions_kind) = string.
 
@@ -1617,17 +1497,17 @@
     mercury_var_to_string(Var, VarSet, no).
 
 :- func failing_contexts_description(module_info, prog_varset,
-    list(failing_context)) = list(error_msg_spec).
+    list(failing_context)) = list(error_msg).
 
 failing_contexts_description(ModuleInfo, VarSet, FailingContexts) =
     list.map(failing_context_description(ModuleInfo, VarSet),
         FailingContexts).
 
 :- func failing_context_description(module_info, prog_varset,
-    failing_context) = error_msg_spec.
+    failing_context) = error_msg.
 
 failing_context_description(ModuleInfo, VarSet, Context - FailingGoal)
-        = Spec :-
+        = Msg :-
     (
         FailingGoal = incomplete_switch(Var),
         VarStr = mercury_var_to_string(Var, VarSet, no),
@@ -1661,7 +1541,7 @@
         FailingGoal = negated_goal,
         Pieces = [words("Negated goal can fail.")]
     ),
-    Spec = error_msg_spec(no, Context, 0, Pieces ++ [nl]).
+    Msg = simple_msg(Context, [always(Pieces ++ [nl])]).
 
 %-----------------------------------------------------------------------------%
 
@@ -1726,15 +1606,6 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pred inst_preserving_append(list(T)::in(list_skel(I)),
-    list(T)::in(list_skel(I)), list(T)::out(list_skel(I))) is det.
-
-inst_preserving_append([], L, L).
-inst_preserving_append([H | T], B, [H | NT]) :-
-    inst_preserving_append(T, B, NT).
-
-%-----------------------------------------------------------------------------%
-
 :- func this_file = string.
 
 this_file = "det_report.m".
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.67
diff -u -b -r1.67 equiv_type.m
--- compiler/equiv_type.m	30 Aug 2006 04:45:58 -0000	1.67
+++ compiler/equiv_type.m	2 Sep 2006 14:17:48 -0000
@@ -1084,19 +1084,15 @@
         TypeDefn = parse_tree_eqv_type(_)
     ->
         Pieces = [words("Error: circular equivalence type"),
-            fixed(describe_sym_name_and_arity(SymName / length(Params))),
-            suffix(".")],
+            sym_name_and_arity(SymName / length(Params)), suffix(".")],
         write_error_pieces(Context, 0, Pieces, !IO)
     ;
         unexpected(this_file, "report_error: invalid item")
     ).
 report_error(invalid_with_type(SymName, PredOrFunc) - Context, !IO) :-
     Pieces = [words("In type declaration for"),
-        words(error_util.pred_or_func_to_string(PredOrFunc)),
-        fixed(error_util.describe_sym_name(SymName)),
-        suffix(":"), nl,
-        words("error: expected higher order"),
-        words(error_util.pred_or_func_to_string(PredOrFunc)),
+        p_or_f(PredOrFunc), sym_name(SymName), suffix(":"), nl,
+        words("error: expected higher order"), p_or_f(PredOrFunc),
         words("type after `with_type`.")],
     write_error_pieces(Context, 0, Pieces, !IO).
 report_error(invalid_with_inst(DeclType, SymName, MaybePredOrFunc) - Context,
@@ -1105,22 +1101,21 @@
     ; DeclType = mode_decl, DeclStr = "mode declaration"
     ),
     (
-        MaybePredOrFunc = no, PredOrFuncStr = ""
+        MaybePredOrFunc = no,
+        PredOrFuncPieces = []
     ;
         MaybePredOrFunc = yes(PredOrFunc),
-        PredOrFuncStr = error_util.pred_or_func_to_string(PredOrFunc)
+        PredOrFuncPieces = [p_or_f(PredOrFunc)]
     ),
-    Pieces = [words("In"), words(DeclStr), words("for"), words(PredOrFuncStr),
-        fixed(error_util.describe_sym_name(SymName)), suffix(":"), nl,
-        words("error: expected higher order "), words(PredOrFuncStr),
-        words("inst after `with_inst`.")],
+    Pieces = [words("In"), words(DeclStr), words("for")] ++
+        PredOrFuncPieces ++ [sym_name(SymName), suffix(":"), nl,
+        words("error: expected higher order ")] ++ PredOrFuncPieces ++
+        [words("inst after `with_inst`.")],
     write_error_pieces(Context, 0, Pieces, !IO).
 report_error(non_matching_with_type_with_inst(SymName, PredOrFunc) - Context,
         !IO) :-
     Pieces = [words("In type declaration for"),
-        words(error_util.pred_or_func_to_string(PredOrFunc)),
-        fixed(error_util.describe_sym_name(SymName)),
-        suffix(":"), nl,
+        p_or_f(PredOrFunc), sym_name(SymName), suffix(":"), nl,
         words("error: the `with_type` and `with_inst`"),
         words("annotations are incompatible.")],
     write_error_pieces(Context, 0, Pieces, !IO).
Index: compiler/error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/error_util.m,v
retrieving revision 1.51
diff -u -b -r1.51 error_util.m
--- compiler/error_util.m	22 Aug 2006 05:03:43 -0000	1.51
+++ compiler/error_util.m	6 Sep 2006 11:43:02 -0000
@@ -36,6 +36,7 @@
 :- module parse_tree.error_util.
 :- interface.
 
+:- import_module libs.options.
 :- import_module mdbcomp.prim_data.
 :- import_module parse_tree.prog_data.
 
@@ -46,10 +47,139 @@
 
 %-----------------------------------------------------------------------------%
 
+% Every distinct problem should generate a single error specification. This
+% specification should state the severity of the problem (so that we can update
+% the exit status of the compiler accordingly), which phase of the compiler
+% found the problem (since later phases may wish to suppress some problem
+% reports if some specific earlier phases found problems, e.g. when a missing
+% clause could be caused by a syntax error), and a specification of what to
+% print.
+%
+% In most cases, the "what to print" will be a single message for a single
+% context. However, we may want to print messages for several contexts.
+% For example, when reporting a duplicate declaration, we want to report
+% this fact in the duplicate declaration's context, while printing another
+% message giving the original declaration's context.
+
+:- type error_spec
+    --->    error_spec(
+                error_severity          :: error_severity,
+                error_phase             :: error_phase,
+                error_msgs              :: list(error_msg)
+            ).
+
+:- type error_severity
+    --->    severity_error
+            % Always set the exit status to indicate an error.
+
+    ;       severity_warning
+            % Only set the exit status to indicate an error if --halt-at-warn
+            % is enabled.
+
+    ;       severity_informational.
+            % Don't set the exit status to indicate an error.
+
+:- type error_phase
+    --->    phase_term_to_parse_tree
+    ;       phase_parse_tree_to_hlds
+    ;       phase_type_check
+    ;       phase_mode_check
+    ;       phase_purity_check
+    ;       phase_detism_check
+    ;       phase_termination_analysis
+    ;       phase_accumulator_intro
+    ;       phase_interface_gen
+    ;       phase_code_gen.
+
+% An error message may have several components that may be printed under
+% different circumstances. Some components are always printed; some are
+% printed only if specific options have specific values. When an error
+% specification is printed, we concatenate the list of all the
+% format_components that should be printed. If this yields the empty list,
+% we print nothing. Otherwise, we give them all to write_error_pieces to print
+% out.
+%
+% When we print an error message in a list of error messages, we normally
+% treat the first line of the first message differently than the rest:
+% we separate it from the context by one space, whereas following lines
+% are separate by three spaces. You can request that the first line of
+% a message be treated as it were the first by setting the error_treat_as_first
+% field to "yes". You can also request that the pieces in a message be given
+% extra indentation by setting the error_extra_indent field to a nonzero value.
+%
+% The term simple_msg(Context, Components) is a shorthand for (and equivalent
+% in every respect to) the term error_msg(yes(Context), no, 0, Components).
+
+:- type error_msg
+    --->    simple_msg(
+                simple_context          :: prog_context,
+                simple_components       :: list(error_msg_component)
+            )
+    ;       error_msg(
+                error_context           :: maybe(prog_context),
+                error_treat_as_first    :: bool,
+                error_extra_indent      :: int,
+                error_components        :: list(error_msg_component)
+            ).
+
+:- type error_msg_component
+    --->    always(format_components)
+            % Print these components under all circumstances.
+
+    ;       option_is_set(option, bool, list(error_msg_component))
+            % Print the embedded components only if the specified boolean
+            % option has the specified value.
+
+    ;       verbose_only(format_components)
+            % Print these components only if --verbose-errors is specified.
+            % If it is not specified, set the flag that triggers the printing
+            % of the message reminding the user about --verbose-errors.
+
+    ;       verbose_and_nonverbose(format_components, format_components)
+            % If --verbose-errors is specified, print the first set of
+            % components. If it is not specified, print the second set,
+            % and set the flag that triggers the printing of the message
+            % reminding the user about --verbose-errors.
+
+    ;       print_anything(pred(io, io)).
+            % This alternative allows the caller to specify an arbitrary thing
+            % to be printed at any point in the sequence. Since things printed
+            % this way aren't formatted as error messages should be (context
+            % at start etc), this capability is intended only for messages
+            % that help debug the compiler itself.
+
+:- pred sort_error_specs(list(error_spec)::in, list(error_spec)::out) is det.
+
+:- pred sort_error_msgs(list(error_msg)::in, list(error_msg)::out) is det.
+
+    % write_error_spec(Spec, !NumWarnings, !NumErrors, !IO):
+    % write_error_specs(Specs, !NumWarnings, !NumErrors, !IO):
+    %
+    % Write out the error message(s) specified by Spec or Specs, minus the
+    % parts whose conditions are false. Increment !NumWarnings by the number
+    % of printed warnings and !NumErrors by the number of printed errors.
+    % Set the exit status to 1 if we found any errors, or if we found any
+    % warnings and --halt-at-warn is set. If some error specs have verbose
+    % components but they aren't being printed out, set the flag for reminding
+    % the user about --verbose-errors.
+    %
+:- pred write_error_spec(error_spec::in, int::in, int::out,
+    int::in, int::out, io::di, io::uo) is det.
+:- pred write_error_specs(list(error_spec)::in, int::in, int::out,
+    int::in, int::out, io::di, io::uo) is det.
+
+%-----------------------------------------------------------------------------%
+
 :- type format_component
     --->    fixed(string)   % This string should appear in the output
                             % in one piece, as it is.
 
+    ;       quote(string)   % Surround the string with `' quotes, then treat
+                            % as fixed.
+
+    ;       int_fixed(int)  % Convert the integer to a string, then treat
+                            % as fixed.
+
     ;       prefix(string)  % This string should appear in the output
                             % in one piece, as it is, inserted directly
                             % before the next format_component, without
@@ -75,11 +205,11 @@
                             % the sym_name, followed by '/' and the arity,
                             % all surrounded by `' quotes.
 
-    ;       pred_or_func(pred_or_func)
+    ;       p_or_f(pred_or_func)
                             % Output the string "predicate" or "function"
                             % as appropriate.
 
-    ;       simple_call_id(simple_call_id)
+    ;       simple_call(simple_call_id)
                             % Output the identity of the given call.
 
     ;       nl              % Insert a line break if there has been text
@@ -89,9 +219,8 @@
                             % Act as nl, but also add the given integer
                             % (which should be a small positive or negative
                             % integer) to the current indent level.
-    
-    ;       quote(string). % Act as fixed, but surround the string by `'
-                           % quotes.
+    ;       blank_line.
+                            % Create a blank line.
 
 :- type format_components == list(format_component).
 
@@ -135,6 +264,11 @@
     %
 :- func choose_number(list(T), U, U) = U.
 
+%-----------------------------------------------------------------------------%
+
+% XXX The predicates below should not be called in new code. New code should
+% create error specifications, and then call write_error_spec to print them.
+
     % Display the given error message, without a context and with standard
     % indentation.
     %
@@ -151,8 +285,8 @@
 
     % write_error_pieces(Context, Indent, Components):
     %
-    % Display `Components' as the error message, with
-    % `Context' as a context and indent by `Indent'.
+    % Display `Components' as the error message, with `Context' as a context
+    % and indent by `Indent'.
     %
 :- pred write_error_pieces(prog_context::in, int::in,
     list(format_component)::in, io::di, io::uo) is det.
@@ -174,60 +308,7 @@
 
 :- func error_pieces_to_string(list(format_component)) = string.
 
-    % An error_msg_spec represents a call write_error_pieces. A call to
-    % write_error_specs will invoke write_error_specs for each element of the
-    % list. Each invocation will use the context given in the error_msg_spec.
-    % The first call will use an indent of zero. By default, all later calls
-    % will use the indent that would be required by the not_first_line variant
-    % of write_error_pieces. However, the first of an error_msg_spec can be
-    % treated as a first line if the treat_as_first_call field is set to yes,
-    % and each call to write_error_pieces will be additionally indented
-    % by the number of levels indicated by the extra_indent field.
-
-:- type error_msg_spec
-    --->    error_msg_spec(
-                spec_treat_as_first     :: bool,
-                spec_context            :: prog_context,
-                spec_extra_indent       :: int,
-                spec_pieces             :: list(format_component)
-            ).
-
-    % In some circumstances, we need more descriptive power than an
-    % error_msg_spec provides.
-    %
-    % The anything alternative allows the caller to specify an arbitrary thing
-    % to be printed at any point in the sequence. Since things printed this way
-    % aren't formatted as error messages should be (context at start etc), this
-    % capability is intended only for messages that help debug the compiler
-    % itself.
-
-:- type extended_error_msg_spec
-    --->    plain_spec(
-                error_msg_spec
-            )
-    ;       anything(
-                spec_write_anything     :: pred(io, io)
-            ).
-
-:- inst extended_error_msg_spec ==
-        bound(
-            plain_spec(ground)
-        ;
-            anything(pred(di, uo) is det)
-        ).
-:- inst extended_error_msg_specs == list_skel(extended_error_msg_spec).
-
-:- pred extend_specs(list(error_msg_spec)::in,
-    list(extended_error_msg_spec)::out(extended_error_msg_specs)) is det.
-
-:- pred add_to_spec_at_end(list(format_component)::in,
-    error_msg_spec::in, error_msg_spec::out) is det.
-
-:- pred write_error_specs(list(error_msg_spec)::in, io::di, io::uo) is det.
-
-:- pred write_extended_error_specs(
-    list(extended_error_msg_spec)::in(extended_error_msg_specs),
-    io::di, io::uo) is det.
+%-----------------------------------------------------------------------------%
 
 :- func describe_sym_name(sym_name) = string.
 
@@ -244,15 +325,6 @@
     %
 :- func capitalize(string) = string.
 
-    % report_error_num_args(MaybePredOrFunc, Arity, CorrectArities).
-    %
-    % Write "wrong number of arguments (<Arity>; should be <CorrectArities>)",
-    % adjusting `Arity' and `CorrectArities' if `MaybePredOrFunc' is
-    % `yes(function)'.
-    %
-:- pred report_error_num_args(maybe(pred_or_func)::in, int::in, list(int)::in,
-    io::di, io::uo) is det.
-
     % Report a warning, and set the exit status to error if the
     % --halt-at-warn option is set.
     %
@@ -268,7 +340,6 @@
 :- import_module parse_tree.prog_util.
 :- import_module libs.compiler_util.
 :- import_module libs.globals.
-:- import_module libs.options.
 
 :- import_module char.
 :- import_module int.
@@ -278,51 +349,206 @@
 
 %-----------------------------------------------------------------------------%
 
-add_to_spec_at_end(NewPieces, Spec0, Spec) :-
-    Spec0 = error_msg_spec(First, Context, ExtraIndent, Pieces0),
-    Pieces = Pieces0 ++ NewPieces,
-    Spec = error_msg_spec(First, Context, ExtraIndent, Pieces).
-
-write_error_specs(Specs, !IO) :-
-    extend_specs(Specs, ExtendedSpecs),
-    do_write_error_specs(ExtendedSpecs, yes, !IO).
-
-write_extended_error_specs(ExtendedSpecs, !IO) :-
-    do_write_error_specs(ExtendedSpecs, yes, !IO).
-
-extend_specs([], []).
-extend_specs([Spec | Specs], [plain_spec(Spec) | ExtendedSpecs]) :-
-    extend_specs(Specs, ExtendedSpecs).
-
-:- pred do_write_error_specs(
-    list(extended_error_msg_spec)::in(extended_error_msg_specs),
-    bool::in, io::di, io::uo) is det.
+sort_error_specs(Specs0, Specs) :-
+    list.sort_and_remove_dups(compare_error_specs, Specs0, Specs).
+
+sort_error_msgs(Msgs0, Msgs) :-
+    list.sort_and_remove_dups(compare_error_msgs, Msgs0, Msgs).
+
+:- pred compare_error_specs(error_spec::in, error_spec::in,
+    comparison_result::out) is det.
+
+compare_error_specs(SpecA, SpecB, Result) :-
+    SpecA = error_spec(_, _, MsgsA),
+    SpecB = error_spec(_, _, MsgsB),
+    ContextsA = project_msgs_contexts(MsgsA),
+    ContextsB = project_msgs_contexts(MsgsB),
+    compare(ContextResult, ContextsA, ContextsB),
+    ( ContextResult = (=) ->
+        compare(Result, SpecA, SpecB)
+    ;
+        Result = ContextResult
+    ).
+
+:- func project_msgs_contexts(list(error_msg)) = list(prog_context).
+
+project_msgs_contexts([]) = [].
+project_msgs_contexts([Msg | Msgs]) = Contexts :-
+    TailContexts = project_msgs_contexts(Msgs),
+    MaybeContext = project_msg_context(Msg),
+    (
+        MaybeContext = yes(Context),
+        Contexts = [Context | TailContexts]
+    ;
+        MaybeContext = no,
+        Contexts = TailContexts
+    ).
+
+:- pred compare_error_msgs(error_msg::in, error_msg::in,
+    comparison_result::out) is det.
+
+compare_error_msgs(MsgA, MsgB, Result) :-
+    MaybeContextA = project_msg_context(MsgA),
+    MaybeContextB = project_msg_context(MsgB),
+    compare(ContextResult, MaybeContextA, MaybeContextB),
+    ( ContextResult = (=) ->
+        compare(Result, MsgA, MsgB)
+    ;
+        Result = ContextResult
+    ).
+
+:- func project_msg_context(error_msg) = maybe(prog_context).
+
+project_msg_context(Msg) = MaybeContext :-
+    (
+        Msg = simple_msg(Context, _),
+        MaybeContext = yes(Context)
+    ;
+        Msg = error_msg(yes(Context), _, _, _),
+        MaybeContext = yes(Context)
+    ;
+        Msg = error_msg(no, _, _, __),
+        MaybeContext = no
+    ).
+
+%-----------------------------------------------------------------------------%
+
+write_error_spec(Spec, !NumWarnings, !NumErrors, !IO) :-
+    write_error_specs([Spec], !NumWarnings, !NumErrors, !IO).
+
+write_error_specs(Specs0, !NumWarnings, !NumErrors, !IO) :-
+    sort_error_specs(Specs0, Specs),
+    io_get_globals(Globals, !IO),
+    io.get_exit_status(OrigExitStatus, !IO),
+    list.foldl3(do_write_error_spec(Globals, OrigExitStatus), Specs,
+        !NumWarnings, !NumErrors, !IO).
 
-do_write_error_specs([], _First, !IO).
-do_write_error_specs([Spec | Specs], !.First, !IO) :-
+:- pred do_write_error_spec(globals::in, int::in, error_spec::in,
+    int::in, int::out, int::in, int::out, io::di, io::uo) is det.
+
+do_write_error_spec(Globals, OrigExitStatus, Spec, !NumWarnings, !NumErrors,
+        !IO) :-
+    Spec = error_spec(Severity, _, Msgs),
+    do_write_error_msgs(Msgs, Globals, OrigExitStatus, yes, no, PrintedSome,
+        !IO),
     (
-        Spec = plain_spec(PlainSpec),
-        PlainSpec = error_msg_spec(TreatAsFirst, Context, ExtraIndent, Pieces),
+        PrintedSome = no
+    ;
+        PrintedSome = yes,
+        (
+            Severity = severity_error,
+            !:NumErrors = !.NumErrors + 1,
+            io.set_exit_status(1, !IO)
+        ;
+            Severity = severity_warning,
+            !:NumWarnings = !.NumWarnings + 1,
+            record_warning(!IO)
+        ;
+            Severity = severity_informational
+        )
+    ).
+
+:- pred do_write_error_msgs(list(error_msg)::in, globals::in, int::in,
+    bool::in, bool::in, bool::out, io::di, io::uo) is det.
+
+do_write_error_msgs([], _Globals, _OrigExitStatus, _First, !PrintedSome, !IO).
+do_write_error_msgs([Msg | Msgs], Globals, OrigExitStatus, !.First,
+        !PrintedSome, !IO) :-
+    (
+        Msg = simple_msg(SimpleContext, Components),
+        MaybeContext = yes(SimpleContext),
+        TreatAsFirst = no,
+        ExtraIndentLevel = 0
+    ;
+        Msg = error_msg(MaybeContext, TreatAsFirst, ExtraIndentLevel,
+            Components)
+    ),
         (
             TreatAsFirst = yes,
             !:First = yes
         ;
             TreatAsFirst = no
         ),
-        Indent = ExtraIndent * indent_increment,
+    Indent = ExtraIndentLevel * indent_increment,
+    write_msg_components(Components, MaybeContext, Indent, Globals,
+        OrigExitStatus, !First, !PrintedSome, !IO),
+    do_write_error_msgs(Msgs, Globals, OrigExitStatus, !.First, !PrintedSome,
+        !IO).
+
+:- pred write_msg_components(list(error_msg_component)::in,
+    maybe(prog_context)::in, int::in, globals::in, int::in,
+    bool::in, bool::out, bool::in, bool::out, io::di, io::uo) is det.
+
+write_msg_components([], _, _, _, _, !First, !PrintedSome, !IO).
+write_msg_components([Component | Components], MaybeContext, Indent, Globals,
+        OrigExitStatus, !First, !PrintedSome, !IO) :-
         (
-            !.First = yes,
-            write_error_pieces(Context, Indent, Pieces, !IO)
+        Component = always(ComponentPieces),
+        do_write_error_pieces(!.First, MaybeContext, Indent,
+            ComponentPieces, !IO),
+        !:First = no,
+        !:PrintedSome = yes
+    ;
+        Component = option_is_set(Option, RequiredValue, EmbeddedComponents),
+        globals.lookup_bool_option(Globals, Option, OptionValue),
+        ( OptionValue = RequiredValue ->
+            write_msg_components(EmbeddedComponents, MaybeContext, Indent,
+                Globals, OrigExitStatus, !First, !PrintedSome, !IO)
+        ;
+            true
+        )
         ;
-            !.First = no,
-            write_error_pieces_not_first_line(Context, Indent, Pieces, !IO)
+        Component = verbose_only(ComponentPieces),
+        globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
+        (
+            VerboseErrors = yes,
+            do_write_error_pieces(!.First, MaybeContext, Indent,
+                ComponentPieces, !IO),
+            !:First = no,
+            !:PrintedSome = yes
+        ;
+            VerboseErrors = no,
+            globals.io_set_extra_error_info(yes, !IO)
+        )
+    ;
+        Component = verbose_and_nonverbose(VerbosePieces, NonVerbosePieces),
+        globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
+        (
+            VerboseErrors = yes,
+            do_write_error_pieces(!.First, MaybeContext, Indent,
+                VerbosePieces, !IO)
+        ;
+            VerboseErrors = no,
+            do_write_error_pieces(!.First, MaybeContext, Indent,
+                NonVerbosePieces, !IO),
+            globals.io_set_extra_error_info(yes, !IO)
         ),
-        !:First = no
+        !:First = no,
+        !:PrintedSome = yes
     ;
-        Spec = anything(Pred),
-        Pred(!IO)
+        Component = print_anything(Anything),
+        unsafe_cast_to_io_pred(Anything, Pred),
+        Pred(!IO),
+        !:First = no,
+        !:PrintedSome = yes
     ),
-    do_write_error_specs(Specs, !.First, !IO).
+    write_msg_components(Components, MaybeContext, Indent, Globals,
+        OrigExitStatus, !First, !PrintedSome, !IO).
+
+:- pred unsafe_cast_to_io_pred(pred(io, io)::in,
+    pred(io, io)::out(pred(di, uo) is det)) is det.
+
+:- pragma foreign_proc("C",
+    unsafe_cast_to_io_pred(Anything::in, Pred::out(pred(di, uo) is det)),
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+    Pred = Anything;
+").
+
+unsafe_cast_to_io_pred(_, _) :-
+    unexpected(this_file, "unsafe_cast_to_io_pred").
+
+%-----------------------------------------------------------------------------%
 
 string_to_words_piece(Str) = words(Str).
 
@@ -358,39 +584,28 @@
 choose_number([_, _ | _], _Singular, Plural) = Plural.
 
 write_error_pieces_plain(Components, !IO) :-
-    write_error_pieces_maybe_with_context(yes, no, 0, Components, !IO).
+    do_write_error_pieces(yes, no, 0, Components, !IO).
 
 write_error_plain_with_progname(ProgName, Msg, !IO) :-
     write_error_pieces_plain([fixed(ProgName ++ ":"), words(Msg)], !IO).
 
 write_error_pieces(Context, Indent, Components, !IO) :-
-    write_error_pieces_maybe_with_context(yes, yes(Context),
-        Indent, Components, !IO).
+    do_write_error_pieces(yes, yes(Context), Indent, Components, !IO).
 
 write_error_pieces_not_first_line(Context, Indent, Components, !IO) :-
-    write_error_pieces_maybe_with_context(no, yes(Context),
-        Indent, Components, !IO).
+    do_write_error_pieces(no, yes(Context), Indent, Components, !IO).
 
 write_error_pieces_maybe_first_line(IsFirst, Context, Indent, Components,
         !IO) :-
-    (
-        IsFirst = yes,
-        write_error_pieces(Context, Indent, Components, !IO)
-    ;
-        IsFirst = no,
-        write_error_pieces_not_first_line(Context, Indent, Components, !IO)
-    ).
+    do_write_error_pieces(IsFirst, yes(Context), Indent, Components, !IO).
 
 write_error_pieces_maybe_with_context(MaybeContext, Indent, Components, !IO) :-
-    write_error_pieces_maybe_with_context(yes, MaybeContext,
-        Indent, Components, !IO).
+    do_write_error_pieces(yes, MaybeContext, Indent, Components, !IO).
 
-:- pred write_error_pieces_maybe_with_context(bool::in,
-    maybe(prog_context)::in, int::in, list(format_component)::in,
-    io::di, io::uo) is det.
+:- pred do_write_error_pieces(bool::in, maybe(prog_context)::in, int::in,
+    list(format_component)::in, io::di, io::uo) is det.
 
-write_error_pieces_maybe_with_context(IsFirst, MaybeContext,
-        FixedIndent, Components, !IO) :-
+do_write_error_pieces(IsFirst, MaybeContext, FixedIndent, Components, !IO) :-
     (
             % The fixed characters at the start of the line are:
             % filename
@@ -447,7 +662,8 @@
 
 :- pred write_line(list(string)::in, io::di, io::uo) is det.
 
-write_line([], !IO).
+write_line([], !IO) :-
+    io.write_char('\n', !IO).
 write_line([Word | Words], !IO) :-
     io.write_string(Word, !IO),
     write_line_rest(Words, !IO),
@@ -468,6 +684,12 @@
         Component = fixed(Word),
         Str = join_string_and_tail(Word, Components, TailStr)
     ;
+        Component = quote(Word),
+        Str = join_string_and_tail(add_quotes(Word), Components, TailStr)
+    ;
+        Component = int_fixed(Int),
+        Str = join_string_and_tail(int_to_string(Int), Components, TailStr)
+    ;
         Component = prefix(Word),
         Str = Word ++ TailStr
     ;
@@ -485,11 +707,11 @@
         Word = sym_name_and_arity_to_word(SymNameAndArity),
         Str = join_string_and_tail(Word, Components, TailStr)
     ;
-        Component = pred_or_func(PredOrFunc),
+        Component = p_or_f(PredOrFunc),
         Word = pred_or_func_to_string(PredOrFunc),
         Str = join_string_and_tail(Word, Components, TailStr)
     ;
-        Component = simple_call_id(SimpleCallId),
+        Component = simple_call(SimpleCallId),
         Word = simple_call_id_to_string(SimpleCallId),
         Str = join_string_and_tail(Word, Components, TailStr)
     ;
@@ -500,8 +722,8 @@
         % There is nothing we can do about the indent delta.
         Str = "\n" ++ TailStr
     ;
-        Component = quote(Word),
-        Str = join_string_and_tail(add_quotes(Word), Components, TailStr)
+        Component = blank_line,
+        Str = "\n\n" ++ TailStr
     ).
 
 :- func join_string_and_tail(string, list(format_component), string) = string.
@@ -521,6 +743,8 @@
     --->    paragraph(
                 list(string),   % The list of words to print in the paragraph.
                                 % It should not be empty.
+                int,            % The number of blank lines to print after
+                                % the paragraph.
                 int             % The indent delta to apply for the next
                                 % paragraph.
             ).
@@ -541,13 +765,19 @@
 
 convert_components_to_paragraphs_acc([], RevWords0, !Paras) :-
     Strings = rev_words_to_strings(RevWords0),
-    list.reverse([paragraph(Strings, 0) | !.Paras], !:Paras).
+    list.reverse([paragraph(Strings, 0, 0) | !.Paras], !:Paras).
 convert_components_to_paragraphs_acc([Component | Components], RevWords0,
         !Paras) :-
     (
         Component = fixed(Word),
         RevWords1 = [plain_word(Word) | RevWords0]
     ;
+        Component = quote(Word),
+        RevWords1 = [plain_word(add_quotes(Word)) | RevWords0]
+    ;
+        Component = int_fixed(Int),
+        RevWords1 = [plain_word(int_to_string(Int)) | RevWords0]
+    ;
         Component = prefix(Word),
         RevWords1 = [prefix_word(Word) | RevWords0]
     ;
@@ -564,26 +794,28 @@
         Word = sym_name_and_arity_to_word(SymNameAndArity),
         RevWords1 = [plain_word(Word) | RevWords0]
     ;
-        Component = pred_or_func(PredOrFunc),
+        Component = p_or_f(PredOrFunc),
         Word = pred_or_func_to_string(PredOrFunc),
         RevWords1 = [plain_word(Word) | RevWords0]
     ;
-        Component = simple_call_id(SimpleCallId),
+        Component = simple_call(SimpleCallId),
         WordsStr = simple_call_id_to_string(SimpleCallId),
         break_into_words(WordsStr, RevWords0, RevWords1)
     ;
         Component = nl,
         Strings = rev_words_to_strings(RevWords0),
-        list.cons(paragraph(Strings, 0), !Paras),
+        list.cons(paragraph(Strings, 0, 0), !Paras),
         RevWords1 = []
     ;
         Component = nl_indent_delta(IndentDelta),
         Strings = rev_words_to_strings(RevWords0),
-        list.cons(paragraph(Strings, IndentDelta), !Paras),
+        list.cons(paragraph(Strings, 0, IndentDelta), !Paras),
         RevWords1 = []
     ;
-        Component = quote(Word),
-        RevWords1 = [plain_word(add_quotes(Word)) | RevWords0]
+        Component = blank_line,
+        Strings = rev_words_to_strings(RevWords0),
+        list.cons(paragraph(Strings, 1, 0), !Paras),
+        RevWords1 = []
     ),
     convert_components_to_paragraphs_acc(Components, RevWords1, !Paras).
 
@@ -652,14 +884,13 @@
 
 :- func sym_name_to_word(sym_name) = string.
 
-sym_name_to_word(SymName) = "`" ++ SymStr ++ "'" :-
-    sym_name_to_string(SymName, SymStr).
+sym_name_to_word(SymName) =
+    "`" ++ sym_name_to_string(SymName) ++ "'".
 
 :- func sym_name_and_arity_to_word(sym_name_and_arity) = string.
 
 sym_name_and_arity_to_word(SymName / Arity) =
-        "`" ++ sym_name_to_string(SymName) ++ "'"
-        ++ "/" ++ int_to_string(Arity).
+    "`" ++ sym_name_to_string(SymName) ++ "'" ++ "/" ++ int_to_string(Arity).
 
 :- pred break_into_words(string::in, list(word)::in, list(word)::out) is det.
 
@@ -729,7 +960,7 @@
         Lines = []
     ;
         Paras = [FirstPara | LaterParas],
-        FirstPara = paragraph(FirstParaWords, FirstIndentDelta),
+        FirstPara = paragraph(FirstParaWords, NumBlankLines, FirstIndentDelta),
         (
             IsFirst = yes,
             RestIndent = CurIndent + 1
@@ -738,9 +969,13 @@
             RestIndent = CurIndent
         ),
         NextIndent = RestIndent + FirstIndentDelta,
+
+        BlankLine = line(CurIndent, []),
+        list.duplicate(NumBlankLines, BlankLine, BlankLines),
         (
             FirstParaWords = [],
-            group_words(IsFirst, NextIndent, LaterParas, Max, Lines)
+            group_words(IsFirst, NextIndent, LaterParas, Max, RestLines),
+            Lines = BlankLines ++ RestLines
         ;
             FirstParaWords = [FirstWord | LaterWords],
             get_line_of_words(FirstWord, LaterWords, CurIndent, Max,
@@ -752,7 +987,7 @@
             ParaLines = [CurLine | ParaRestLines],
 
             group_words(no, NextIndent, LaterParas, Max, RestLines),
-            Lines = ParaLines ++ RestLines
+            Lines = ParaLines ++ BlankLines ++ RestLines
         )
     ).
 
@@ -798,10 +1033,10 @@
 
 %-----------------------------------------------------------------------------%
 
-describe_sym_name_and_arity(SymName / Arity) =
-        string.append_list(["`", SymNameString, "/",
-            string.int_to_string(Arity), "'"]) :-
-    sym_name_to_string(SymName, SymNameString).
+describe_sym_name_and_arity(SymName / Arity) = String :-
+    sym_name_to_string(SymName, SymNameString),
+    String = string.append_list(["`", SymNameString, "/",
+        string.int_to_string(Arity), "'"]).
 
 describe_sym_name(SymName) = string.append_list(["`", SymNameString, "'"]) :-
     sym_name_to_string(SymName, SymNameString).
@@ -826,42 +1061,6 @@
 
 %-----------------------------------------------------------------------------%
 
-report_error_num_args(MaybePredOrFunc, Arity0, Arities0, !IO) :-
-    % Adjust arities for functions.
-    ( MaybePredOrFunc = yes(function) ->
-        adjust_func_arity(function, Arity, Arity0),
-        list.map(
-            (pred(OtherArity0::in, OtherArity::out) is det :-
-                adjust_func_arity(function, OtherArity, OtherArity0)
-            ),
-            Arities0, Arities)
-    ;
-        Arity = Arity0,
-        Arities = Arities0
-    ),
-    io.write_string("wrong number of arguments (", !IO),
-    io.write_int(Arity, !IO),
-    io.write_string("; should be ", !IO),
-    report_error_right_num_args(Arities, !IO),
-    io.write_string(")", !IO).
-
-:- pred report_error_right_num_args(list(int)::in, io::di, io::uo) is det.
-
-report_error_right_num_args([], !IO).
-report_error_right_num_args([Arity | Arities], !IO) :-
-    io.write_int(Arity, !IO),
-    (
-        Arities = [],
-        true
-    ;
-        Arities = [_],
-        io.write_string(" or ", !IO)
-    ;
-        Arities = [_, _ | _],
-        io.write_string(", ", !IO)
-    ),
-    report_error_right_num_args(Arities, !IO).
-
 report_warning(Context, Indent, Components, !IO) :-
     record_warning(!IO),
     write_error_pieces(Context, Indent, Components, !IO).
Index: compiler/fact_table.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.78
diff -u -b -r1.78 fact_table.m
--- compiler/fact_table.m	22 Aug 2006 05:03:44 -0000	1.78
+++ compiler/fact_table.m	7 Sep 2006 00:44:11 -0000
@@ -398,7 +398,7 @@
         term.functor(Const, Terms0, Context), FactArgInfos,
         ProcStreams, MaybeOutput, FactNum, Result, !Errors, !IO) :-
     PredOrFunc = pred_info_is_pred_or_func(PredInfo),
-    unqualify_name(PredName, PredString),
+    PredString = unqualify_name(PredName),
     ( Const = term.atom(TopLevel) ->
         (
             (
Index: compiler/hlds_error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_error_util.m,v
retrieving revision 1.22
diff -u -b -r1.22 hlds_error_util.m
--- compiler/hlds_error_util.m	22 Aug 2006 05:03:46 -0000	1.22
+++ compiler/hlds_error_util.m	7 Sep 2006 00:44:33 -0000
@@ -30,7 +30,7 @@
 
 %-----------------------------------------------------------------------------%
 %
-% Predicates to convert predicate and procedure names to strings
+% Predicates to convert predicate and procedure names to strings.
 %
 
 :- type should_module_qualify
@@ -102,7 +102,14 @@
     pred_info_get_origin(PredInfo, Origin),
     ( Origin = origin_special_pred(SpecialId - TypeCtor) ->
         special_pred_description(SpecialId, Descr),
-        TypeCtor = type_ctor(TypeSymName, TypeArity),
+        TypeCtor = type_ctor(TypeSymName0, TypeArity),
+        (
+            ShouldModuleQualify = should_module_qualify,
+            TypeSymName = TypeSymName0
+        ;
+            ShouldModuleQualify = should_not_module_qualify,
+            TypeSymName = unqualified(unqualify_name(TypeSymName0))
+        ),
         ( TypeArity = 0 ->
             Pieces = [words(Descr), words("for type"),
                 sym_name(TypeSymName)]
@@ -117,20 +124,18 @@
             words("declaration")]
     ;
         ( check_marker(Markers, marker_class_method) ->
-            Prefix = [words("type class"), pred_or_func(PredOrFunc),
-                words("method")]
+            Prefix = [words("type class"), p_or_f(PredOrFunc), words("method")]
         ;
-            Prefix = [pred_or_func(PredOrFunc)]
+            Prefix = [p_or_f(PredOrFunc)]
         ),
-        string.int_to_string(OrigArity, ArityPart),
-        string.append_list([
-            "`",
-            module_qualification(ModuleName, ShouldModuleQualify),
-            PredName,
-            "/",
-            ArityPart,
-            "'"], SpecStr),
-        Pieces = Prefix ++ [fixed(SpecStr)]
+        (
+            ShouldModuleQualify = should_module_qualify,
+            PredSymName = qualified(ModuleName, PredName)
+        ;
+            ShouldModuleQualify = should_not_module_qualify,
+            PredSymName = unqualified(PredName)
+        ),
+        Pieces = Prefix ++ [sym_name_and_arity(PredSymName / OrigArity)]
     ).
 
 describe_one_pred_name_mode(Module, ShouldModuleQualify, PredId, InstVarSet,
@@ -162,8 +167,8 @@
         "`",
         module_qualification(ModuleName, ShouldModuleQualify),
         PredName,
-        ArgModesPart,
-        "'"], Descr),
+        "'",
+        ArgModesPart], Descr),
     Pieces = [words(Descr)].
 
 describe_several_pred_names(Module, ShouldModuleQualify, PredIds) = Pieces :-
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.139
diff -u -b -r1.139 hlds_module.m
--- compiler/hlds_module.m	20 Aug 2006 08:21:10 -0000	1.139
+++ compiler/hlds_module.m	31 Aug 2006 13:56:25 -0000
@@ -9,14 +9,13 @@
 % File: hlds_module.m.
 % Main authors: fjh, conway.
 % 
-% This module defines the part of the High Level Data Structure or HLDS
-% that deals with issues that are wider than a single predicate.
+% This module defines the main part of the High Level Data Structure or HLDS
+% that deals with issues that concern the module as a whole.
 % 
 % The main data structures defined here are the types
 %
 %   module_info
 %   dependency_info
-%   predicate_table
 %
 % There is a separate interface section for each of these.
 % 
@@ -135,15 +134,15 @@
 
 :- type proc_mm_tabling_info
     --->    proc_mm_tabling_info(
-                proc_mm_status :: mm_tabling_status,
                 % The tabling status for this procedures as determined
                 % by tabling analysis.
+                proc_mm_status                      :: mm_tabling_status,
                 
-                proc_mm_analysis_status :: maybe(analysis_status)
                 % The status of the tabling analysis results for this
                 % procedure.  This is used by the intermodule-analysis
                 % framework to determine if there is any benefit in
                 % re-analysing this procedure.
+                proc_mm_analysis_status             :: maybe(analysis_status)
             ).
 
     % List of procedures for which there are user-requested type
@@ -152,30 +151,24 @@
     % versions.
 :- type type_spec_info
     --->    type_spec_info(
+                % Procedures for which there are user-requested type
+                % specializations.
                 user_req_procs      :: set(pred_proc_id),
-                                    % Procedures for which there are
-                                    % user-requested type specializations.
 
+                % Set of predicates which need to be processed by
+                % higher_order.m to produce those specialized versions.
                 must_process_preds  ::  set(pred_id),
-                                    % Set of predicates which need to be
-                                    % processed by higher_order.m to
-                                    % produce those specialized versions.
 
+                % Map from predicates for which the user requested a type
+                % specialization to the list of predicates which must be
+                % processed by higher_order.m to force the production of those
+                % versions. This is used by dead_proc_elim.m to avoid creating
+                % versions unnecessarily for versions in imported modules.
                 user_to_process_map :: multi_map(pred_id, pred_id),
-                                    % Map from predicates for which the
-                                    % user requested a type specialization
-                                    % to the list of predicates which must
-                                    % be processed by higher_order.m to
-                                    % force the production of those
-                                    % versions. This is used by
-                                    % dead_proc_elim.m to avoid creating
-                                    % versions unnecessarily for versions
-                                    % in imported modules.
 
+                % Type spec pragmas to be placed in the `.opt' file if a
+                % predicate becomes exported.
                 pragma_map          :: multi_map(pred_id, pragma_type)
-                                    % Type spec pragmas to be placed in
-                                    % the `.opt' file if a predicate
-                                    % becomes exported.
             ).
 
     % Maps the full names of procedures (in the sense of
@@ -185,14 +178,14 @@
 
 :- type complexity_proc_info
     --->    complexity_proc_info(
+                % The index of the procedure in the runtime system's
+                % MR_complexity_procs array.
                 complexity_proc_num     :: int,
-                            % The index of the procedure in the runtime
-                            % system's MR_complexity_procs array.
 
-                complexity_proc_name    :: string,
                             % The full name of the procedure, in the form
-                            % fqn/arity-modenum, where fqn is the predicate or
-                            % function's fully qualified name.
+                % fqn/arity-modenum, where fqn is the predicate or function's
+                % fully qualified name.
+                complexity_proc_name    :: string,
 
                 complexity_proc_args    :: list(complexity_arg_info)
             ).
@@ -208,22 +201,21 @@
     ;       complexity_input_fixed_size
     ;       complexity_output.
 
-        % This type is used to record the mapping between original
-        % procedures, and their optimised versions with respect to 
-        % structure reuse (CTGC). 
+    % This type is used to record the mapping between original procedures,
+    % and their optimised versions with respect to structure reuse (CTGC).
         %
 :- type structure_reuse_map == 
     map(pred_proc_id, pair(pred_proc_id, sym_name)).
+
 %-----------------------------------------------------------------------------%
 %
 % Various predicates for manipulating the module_info data structure
 %
 
     % Create an empty module_info for a given module name (and the
-    % global options).  The item_list is passed so that we can
-    % call get_implicit_dependencies to figure out whether to
-    % import `table_builtin', but the items are not inserted into
-    % the module_info.
+    % global options). The item_list is passed so that we can call
+    % get_implicit_dependencies to figure out whether to import
+    % `table_builtin', but the items are not inserted into the module_info.
     %
 :- pred module_info_init(module_name::in, item_list::in, globals::in,
     partial_qualifier_info::in, maybe(recompilation_info)::in,
@@ -329,6 +321,7 @@
     % any ancestor modules and any modules imported by ancestor modules.
     % It excludes transitively imported modules (those for which we read
     % `.int2' files).
+    %
 :- pred visible_module(module_name::out, module_info::in) is multi.
 
     % This returns all the modules that this module's code depends on,
@@ -585,6 +578,9 @@
 
 :- pred module_info_incr_errors(module_info::in, module_info::out) is det.
 
+:- pred module_info_incr_num_errors(int::in,
+    module_info::in, module_info::out) is det.
+
     % The module_info stores a counter which is used to distinguish
     % lambda predicates which appear on the same line in the same file.
     % This predicate returns the next number for the given context
@@ -778,7 +774,7 @@
     map.init(InstanceTable),
     map.init(SuperClassTable),
 
-    % the builtin modules are automatically imported
+    % The builtin modules are automatically imported.
     get_implicit_dependencies(Items, Globals, ImportDeps, UseDeps),
     set.list_to_set(ImportDeps ++ UseDeps, ImportedModules),
     set.init(IndirectlyImportedModules),
@@ -1103,8 +1099,11 @@
     module_info_set_maybe_dependency_info(no, !MI).
 
 module_info_incr_errors(!MI) :-
+    module_info_incr_num_errors(1, !MI).
+
+module_info_incr_num_errors(Incr, !MI) :-
     module_info_get_num_errors(!.MI, Errs0),
-    Errs = Errs0 + 1,
+    Errs = Errs0 + Incr,
     module_info_set_num_errors(Errs, !MI).
 
 module_info_next_lambda_count(Context, Count, !MI) :-
@@ -1173,8 +1172,7 @@
 
 module_add_foreign_decl(Lang, IsLocal, ForeignDecl, Context, !Module) :-
     module_info_get_foreign_decl(!.Module, ForeignDeclIndex0),
-        % store the decls in reverse order and reverse them later
-        % for efficiency
+    % Store the decls in reverse order and reverse them later for efficiency.
     ForeignDeclIndex = [foreign_decl_code(Lang, IsLocal, ForeignDecl,
         Context) | ForeignDeclIndex0],
     module_info_set_foreign_decl(ForeignDeclIndex, !Module).
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.401
diff -u -b -r1.401 hlds_out.m
--- compiler/hlds_out.m	5 Sep 2006 06:21:25 -0000	1.401
+++ compiler/hlds_out.m	5 Sep 2006 06:27:12 -0000
@@ -107,9 +107,9 @@
     % The bool returned as the second argument will be `no' unless nothing
     % was printed out, in which case it will be the same as the first arg.
     %
-:- pred write_unify_context(bool::in, bool::out, unify_context::in,
+:- pred write_unify_context_first(bool::in, bool::out, unify_context::in,
     prog_context::in, io::di, io::uo) is det.
-:- pred unify_context_to_pieces(bool::in, bool::out, unify_context::in,
+:- pred unify_context_first_to_pieces(bool::in, bool::out, unify_context::in,
     list(format_component)::in, list(format_component)::out) is det.
 
 :- pred write_determinism(determinism::in, io::di, io::uo) is det.
@@ -534,18 +534,18 @@
 %-----------------------------------------------------------------------------%
 
 write_unify_context(UnifyContext, Context, !IO) :-
-    write_unify_context(no, _, UnifyContext, Context, !IO).
+    write_unify_context_first(no, _, UnifyContext, Context, !IO).
 
 unify_context_to_pieces(UnifyContext, !Pieces) :-
-    unify_context_to_pieces(no, _, UnifyContext, !Pieces).
+    unify_context_first_to_pieces(no, _, UnifyContext, !Pieces).
 
-write_unify_context(!First, UnifyContext, Context, !IO) :-
+write_unify_context_first(!First, UnifyContext, Context, !IO) :-
     UnifyContext = unify_context(MainContext, RevSubContexts),
     list.reverse(RevSubContexts, SubContexts),
     write_unify_main_context(!First, MainContext, Context, !IO),
     write_unify_sub_contexts(!First, SubContexts, Context, !IO).
 
-unify_context_to_pieces(!First, UnifyContext, !Pieces) :-
+unify_context_first_to_pieces(!First, UnifyContext, !Pieces) :-
     UnifyContext = unify_context(MainContext, RevSubContexts),
     list.reverse(RevSubContexts, SubContexts),
     unify_main_context_to_pieces(!First, MainContext, !Pieces),
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.209
diff -u -b -r1.209 hlds_pred.m
--- compiler/hlds_pred.m	5 Sep 2006 06:21:26 -0000	1.209
+++ compiler/hlds_pred.m	7 Sep 2006 00:44:46 -0000
@@ -253,30 +253,33 @@
                 % Defined in the implementation of this module, and the module
                 % does not contain any sub-modules.
 
-    % Returns yes if the status indicates that the item was
-    % in any way exported -- that is, if it could be used
-    % by any other module, or by sub-modules of this module.
+    % Returns yes if the status indicates that the item was in any way exported
+    % -- that is, if it could be used by any other module, or by sub-modules
+    % of this module.
     %
 :- func status_is_exported(import_status) = bool.
 
-    % Returns yes if the status indicates that the item was
-    % exported to importing modules (not just to sub-modules).
+    % Returns yes if the status indicates that the item was exported
+    % to importing modules (not just to sub-modules).
     %
 :- func status_is_exported_to_non_submodules(import_status) = bool.
 
-    % Returns yes if the status indicates that the item was
-    % in any way imported -- that is, if it was defined in
-    % some other module, or in a sub-module of this module.
-    % This is the opposite of status_defined_in_this_module.
+    % Returns yes if the status indicates that the item was in any way imported
+    % -- that is, if it was defined in some other module, or in a sub-module
+    % of this module. This is the opposite of status_defined_in_this_module.
     %
 :- func status_is_imported(import_status) = bool.
 
-    % Returns yes if the status indicates that the item was
-    % defined in this module.  This is the opposite of
-    % status_is_imported.
+    % Returns yes if the status indicates that the item was defined in this
+    % module. This is the opposite of status_is_imported.
     %
 :- func status_defined_in_this_module(import_status) = bool.
 
+    % Returns yes if the import_status indicates the item came from
+    % the implementation section.
+    %
+:- func status_defined_in_impl_section(import_status) = bool.
+
     % Are calls from a predicate with the given import_status always fully
     % qualified. For calls occurring in `.opt' files this will return
     % `is_fully_qualified', otherwise `may_be_partially_qualified'.
@@ -876,6 +879,28 @@
 status_defined_in_this_module(status_exported_to_submodules) =  yes.
 status_defined_in_this_module(status_local) =                   yes.
 
+status_defined_in_impl_section(status_abstract_exported) =      yes.
+status_defined_in_impl_section(status_exported_to_submodules) = yes.
+status_defined_in_impl_section(status_local) =                  yes.
+status_defined_in_impl_section(status_opt_imported) =           no.
+status_defined_in_impl_section(status_abstract_imported) =      no.
+status_defined_in_impl_section(status_pseudo_imported) =        no.
+status_defined_in_impl_section(status_exported) =               no.
+status_defined_in_impl_section(status_opt_exported) =           yes.
+status_defined_in_impl_section(status_pseudo_exported) =        no.
+status_defined_in_impl_section(status_external(Status)) =
+    status_defined_in_impl_section(Status).
+status_defined_in_impl_section(status_imported(ImportLocn)) =
+    import_locn_defined_in_impl_section(ImportLocn).
+
+:- func import_locn_defined_in_impl_section(import_locn) = bool.
+
+import_locn_defined_in_impl_section(import_locn_implementation) = yes.
+import_locn_defined_in_impl_section(import_locn_interface) = yes.
+import_locn_defined_in_impl_section(import_locn_ancestor) = yes.
+import_locn_defined_in_impl_section(import_locn_ancestor_private_interface)
+    = yes.
+
 calls_are_fully_qualified(Markers) =
     ( check_marker(Markers, marker_calls_are_fully_qualified) ->
         is_fully_qualified
@@ -994,7 +1019,7 @@
 pred_info_init(ModuleName, SymName, Arity, PredOrFunc, Context, Origin, Status,
         GoalType, Markers, ArgTypes, TypeVarSet, ExistQVars, ClassContext,
         ClassProofs, ClassConstraintMap, ClausesInfo, PredInfo) :-
-    unqualify_name(SymName, PredName),
+    PredName = unqualify_name(SymName),
     sym_name_get_module_name(SymName, ModuleName, PredModuleName),
     prog_type.vars_list(ArgTypes, TVars),
     list.delete_elems(TVars, ExistQVars, HeadTypeParams),
@@ -1020,7 +1045,7 @@
     proc_info_get_varset(ProcInfo, VarSet),
     proc_info_get_vartypes(ProcInfo, VarTypes),
     proc_info_get_headvars(ProcInfo, HeadVars),
-    unqualify_name(SymName, PredName),
+    PredName = unqualify_name(SymName),
     Attributes = [],
     map.init(ClassProofs),
     map.init(ClassConstraintMap),
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.207
diff -u -b -r1.207 intermod.m
--- compiler/intermod.m	5 Sep 2006 06:21:26 -0000	1.207
+++ compiler/intermod.m	7 Sep 2006 00:44:54 -0000
@@ -956,7 +956,7 @@
         TypeCtors = [TheTypeCtor],
         MaybePredId = no,
         ( TheTypeCtor = type_ctor(qualified(TypeModule, _), _) ->
-            unqualify_name(InstanceMethodName0, UnqualMethodName),
+            UnqualMethodName = unqualify_name(InstanceMethodName0),
             InstanceMethodName = qualified(TypeModule, UnqualMethodName)
         ;
             unexpected(this_file, "unqualified type_ctor in " ++
Index: compiler/make_hlds_error.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_error.m,v
retrieving revision 1.10
diff -u -b -r1.10 make_hlds_error.m
--- compiler/make_hlds_error.m	20 Aug 2006 08:21:15 -0000	1.10
+++ compiler/make_hlds_error.m	2 Sep 2006 15:15:15 -0000
@@ -194,9 +194,9 @@
         true
     ;
         Pieces = [words("Error:"), words(Description), words("for"),
-            words(simple_call_id_to_string(PredOrFunc, Name, Arity)), nl,
+            simple_call(simple_call_id(PredOrFunc, Name, Arity)), nl,
             words("without preceding"),
-            fixed("`" ++ pred_or_func_to_str(PredOrFunc) ++ "'"),
+            quote(pred_or_func_to_str(PredOrFunc)),
             words("declaration.")],
         write_error_pieces(Context, 0, Pieces, !IO),
         io.set_exit_status(1, !IO)
Index: compiler/make_hlds_passes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_passes.m,v
retrieving revision 1.51
diff -u -b -r1.51 make_hlds_passes.m
--- compiler/make_hlds_passes.m	30 Aug 2006 04:45:59 -0000	1.51
+++ compiler/make_hlds_passes.m	7 Sep 2006 00:45:13 -0000
@@ -829,11 +829,10 @@
         (
             Origin = user,
             list.length(Args, Arity),
-            %
+
             % There is no point printing out the qualified name since that
             % information is already in the context.
-            %
-            unqualify_name(PredName, UnqualifiedPredName),
+            UnqualifiedPredName = unqualify_name(PredName),
             ClauseId = simple_call_id_to_string(PredOrFunc,
                 unqualified(UnqualifiedPredName) / Arity),
             error_is_exported(Context, "clause for " ++ ClauseId, !IO),
@@ -2079,7 +2078,7 @@
 
 report_field_status_mismatch(Context, CallId, !IO) :-
     ErrorPieces = [
-        words("In declaration of"), simple_call_id(CallId), suffix(":"), nl,
+        words("In declaration of"), simple_call(CallId), suffix(":"), nl,
         words("error: a field access function for an"),
         words("exported field must also be exported.")
     ],
Index: compiler/make_hlds_warn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_warn.m,v
retrieving revision 1.16
diff -u -b -r1.16 make_hlds_warn.m
--- compiler/make_hlds_warn.m	22 Aug 2006 05:03:52 -0000	1.16
+++ compiler/make_hlds_warn.m	2 Sep 2006 14:40:19 -0000
@@ -340,7 +340,7 @@
         ;
             UnmentionedVars = [_ | _],
             Pieces = [words("In the " ++ LangStr ++ " code for"),
-                simple_call_id(PredOrFuncCallId), suffix(":"), nl,
+                simple_call(PredOrFuncCallId), suffix(":"), nl,
                 words(variable_warning_start(UnmentionedVars)),
                 words("not occur in the " ++ LangStr ++ " code.")],
             write_error_pieces(Context, 0, Pieces, !IO)
@@ -363,7 +363,7 @@
         ;
             UnmentionedInputVars = [_ | _],
             Pieces1 = [words("In the " ++ LangStr ++ " code for"),
-                simple_call_id(PredOrFuncCallId), suffix(":"), nl,
+                simple_call(PredOrFuncCallId), suffix(":"), nl,
                 words(variable_warning_start(UnmentionedInputVars)),
                 words("not occur in the first " ++ LangStr ++ " code.")],
             write_error_pieces(Context, 0, Pieces1, !IO)
@@ -381,7 +381,7 @@
         ;
             UnmentionedFirstOutputVars = [_ | _],
             Pieces2 = [words("In the " ++ LangStr ++ " code for"),
-                simple_call_id(PredOrFuncCallId), suffix(":"), nl,
+                simple_call(PredOrFuncCallId), suffix(":"), nl,
                 words(variable_warning_start(UnmentionedFirstOutputVars)),
                 words("not occur in the first " ++ LangStr ++
                     " code or the shared " ++ LangStr ++ " code.")],
@@ -400,7 +400,7 @@
         ;
             UnmentionedLaterOutputVars = [_ | _],
             Pieces3 = [words("In the " ++ LangStr ++ " code for"),
-                simple_call_id(PredOrFuncCallId), suffix(":"), nl,
+                simple_call(PredOrFuncCallId), suffix(":"), nl,
                 words(variable_warning_start(UnmentionedLaterOutputVars)),
                 words("not occur in the retry " ++ LangStr ++
                 " code or the shared " ++ LangStr ++ " code.")],
@@ -538,7 +538,7 @@
                 "' occur only once in this scope."
         ),
         Pieces1 = [words("In clause for"),
-            simple_call_id(PredOrFuncCallId), suffix(":"), nl,
+            simple_call(PredOrFuncCallId), suffix(":"), nl,
             words(SingletonWarn)],
         report_warning(Context, 0, Pieces1, !IO)
     ),
@@ -562,7 +562,7 @@
                 "' occur more than once in this scope."
         ),
         Pieces2 = [words("In clause for"),
-            simple_call_id(PredOrFuncCallId), suffix(":"), nl,
+            simple_call(PredOrFuncCallId), suffix(":"), nl,
             words(MultiWarn)],
         report_warning(Context, 0, Pieces2, !IO)
     ).
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.399
diff -u -b -r1.399 mercury_compile.m
--- compiler/mercury_compile.m	4 Sep 2006 01:47:32 -0000	1.399
+++ compiler/mercury_compile.m	5 Sep 2006 03:40:07 -0000
@@ -953,31 +953,28 @@
             ReturnTimestamp, Items, Error, ModuleName, MaybeTimestamp, !IO),
 
         %
-        % XXX If the module name doesn't match the file name
-        % the compiler won't be able to find the `.used'
-        % file (the name of the `.used' file is derived from
-        % the module name not the file name).
-        % This will be fixed when mmake functionality
-        % is moved into the compiler.
+        % XXX If the module name doesn't match the file name the compiler
+        % won't be able to find the `.used' file (the name of the `.used' file
+        % is derived from the module name not the file name). This will be
+        % fixed when mmake functionality is moved into the compiler.
         %
         globals.io_lookup_bool_option(smart_recompilation, Smart, !IO),
         (
             Smart = yes,
             ModuleName \= DefaultModuleName
         ->
-            globals.io_lookup_bool_option(warn_smart_recompilation, Warn,
-                !IO),
+            globals.io_lookup_bool_option(warn_smart_recompilation, Warn, !IO),
             (
                 Warn = yes,
-                Msg1 = "Warning: module name does not " ++ "match file name: ",
-                ModuleNameStr = describe_sym_name(ModuleName),
-                Msg2 = FileName ++ " contains module `" ++ ModuleNameStr ++
-                    "'.",
-                Msg3 = "Smart recompilation will not work unless " ++
-                    "a module name to file name mapping is created using " ++
-                    "`mmc -f *.m'.",
-                write_error_pieces_plain([words(Msg1), nl, words(Msg2), nl,
-                    words(Msg3)], !IO),
+                Pieces =
+                    [words("Warning:"),
+                    words("module name does not match file name: "), nl,
+                    fixed(FileName), words("contains module"),
+                    sym_name(ModuleName), suffix("."), nl,
+                    words("Smart recompilation will not work unless"),
+                    words("a module name to file name mapping is created"),
+                    words("using `mmc -f *.m'."), nl],
+                write_error_pieces_plain(Pieces, !IO),
                 record_warning(!IO)
             ;
                 Warn = no
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.300
diff -u -b -r1.300 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m	5 Sep 2006 06:21:27 -0000	1.300
+++ compiler/mercury_to_mercury.m	7 Sep 2006 00:46:50 -0000
@@ -884,12 +884,12 @@
     io.write_string("\t", !IO),
     (
         Method = method_pred_or_func(TypeVarSet, InstVarSet, ExistQVars,
-            PredOrFunc, Name0, TypesAndModes, WithType, WithInst,
+            PredOrFunc, SymName, TypesAndModes, WithType, WithInst,
             Detism, _Condition, Purity, ClassContext, Context),
 
         % The module name is implied by the qualifier of the
         % `:- typeclass declaration'.
-        unqualify_name(Name0, Name),
+        Name = unqualify_name(SymName),
         (
             % Function declarations using `with_type` have the
             % same format as predicate declarations, but with
@@ -909,12 +909,12 @@
                 ClassContext, Context, "", ",\n\t", "", !IO)
         )
     ;
-        Method = method_pred_or_func_mode(VarSet, PredOrFunc, Name0, Modes,
+        Method = method_pred_or_func_mode(VarSet, PredOrFunc, SymName, Modes,
             WithInst, Detism, _Condition, Context),
 
         % The module name is implied by the qualifier of the
         % `:- typeclass declaration'.
-        unqualify_name(Name0, Name),
+        Name = unqualify_name(SymName),
         (
             % Function mode declarations using `with_type` have
             % the same format as predicate mode declarations.
@@ -1937,7 +1937,7 @@
 
         % We'll have attached the module name to the type definition,
         % so there's no point adding it to the constructor as well.
-    unqualify_name(SymName, Name),
+    Name = unqualify_name(SymName),
     AppendVarnums = no,
     mercury_output_quantifier(VarSet, AppendVarnums, ExistQVars, !IO),
     (
@@ -2127,7 +2127,7 @@
     (
         PredOrFunc = predicate,
         MaybeDet = no,
-        unqualify_name(PredName, "is"),
+        unqualify_name(PredName) = "is",
         list.length(Types, 2)
     ->
         % This determinism will be ignored.
@@ -4204,9 +4204,8 @@
 
 :- pred maybe_unqualify_sym_name(bool::in, sym_name::in, sym_name::out) is det.
 
-maybe_unqualify_sym_name(no, Name, Name).
-maybe_unqualify_sym_name(yes, Name0, unqualified(Name)) :-
-    unqualify_name(Name0, Name).
+maybe_unqualify_sym_name(no, SymName, SymName).
+maybe_unqualify_sym_name(yes, SymName, unqualified(unqualify_name(SymName))).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.115
diff -u -b -r1.115 ml_code_util.m
--- compiler/ml_code_util.m	22 Aug 2006 05:03:54 -0000	1.115
+++ compiler/ml_code_util.m	7 Sep 2006 00:46:56 -0000
@@ -1568,7 +1568,7 @@
     % otherwise we just use `F' followed by the field number.
     (
         MaybeFieldName = yes(QualifiedFieldName),
-        unqualify_name(QualifiedFieldName, FieldName)
+        FieldName = unqualify_name(QualifiedFieldName)
     ;
         MaybeFieldName = no,
         FieldName = string.format("F%d", [i(ArgNum)])
Index: compiler/ml_tailcall.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_tailcall.m,v
retrieving revision 1.40
diff -u -b -r1.40 ml_tailcall.m
--- compiler/ml_tailcall.m	22 Aug 2006 05:03:55 -0000	1.40
+++ compiler/ml_tailcall.m	6 Sep 2006 03:11:03 -0000
@@ -595,12 +595,13 @@
         SimpleCallId = simple_call_id(PredOrFunc, unqualified(Name), Arity),
         proc_id_to_int(ProcId, ProcNumber0),
         ProcNumber = ProcNumber0 + 1,
-        ProcNumberStr = string.int_to_string(ProcNumber),
-        report_warning(mlds_get_prog_context(Context), 0, [
-            words("In mode number"), words(ProcNumberStr),
-            words("of"), simple_call_id(SimpleCallId), suffix(":"), nl,
-            words("warning: recursive call is not tail recursive.")
-        ], !IO)
+        Pieces =
+            [words("In mode number"), int_fixed(ProcNumber),
+            words("of"), simple_call(SimpleCallId), suffix(":"), nl,
+            words("warning: recursive call is not tail recursive."), nl],
+        Msg = simple_msg(mlds_get_prog_context(Context), [always(Pieces)]),
+        Spec = error_spec(severity_warning, phase_code_gen, [Msg]),
+        write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO)
     ;
         PredLabel = mlds_special_pred_label(_, _, _, _)
         % Don't warn about these.
Index: compiler/ml_type_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_type_gen.m,v
retrieving revision 1.58
diff -u -b -r1.58 ml_type_gen.m
--- compiler/ml_type_gen.m	22 Aug 2006 05:03:55 -0000	1.58
+++ compiler/ml_type_gen.m	7 Sep 2006 00:47:13 -0000
@@ -249,7 +249,7 @@
         "ml_gen_enum_constant: arity != []"),
 
     % Generate an MLDS definition for this enumeration constant.
-    unqualify_name(Name, UnqualifiedName),
+    UnqualifiedName = unqualify_name(Name),
     MLDS_Defn = mlds_defn(entity_data(var(mlds_var_name(UnqualifiedName, no))),
         mlds_make_context(Context),
         ml_gen_enum_constant_decl_flags,
@@ -450,7 +450,7 @@
         % in the `--tags none' case, where there will be no primary tags.
 
         Ctor = ctor(_ExistQTVars, _Constraints, Name, _Args),
-        unqualify_name(Name, UnqualifiedName),
+        UnqualifiedName = unqualify_name(Name),
         ConstValue = const(mlconst_int(SecondaryTag)),
         MLDS_Defn = mlds_defn(
             entity_data(var(mlds_var_name(UnqualifiedName, no))),
@@ -574,7 +574,7 @@
     MLDS_Context = mlds_make_context(Context),
 
     % Generate the class name for this constructor.
-    unqualify_name(CtorName, UnqualCtorName),
+    UnqualCtorName = unqualify_name(CtorName),
     list.length(Args, CtorArity),
 
     TagVal = get_tagval(ConsTagValues, Ctor),
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.106
diff -u -b -r1.106 ml_unify_gen.m
--- compiler/ml_unify_gen.m	22 Aug 2006 05:03:56 -0000	1.106
+++ compiler/ml_unify_gen.m	7 Sep 2006 00:47:30 -0000
@@ -491,7 +491,7 @@
         module_info_get_globals(ModuleInfo, Globals),
         MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName),
         TypeCtor = type_ctor(TypeName, TypeArity),
-        unqualify_name(TypeName, UnqualTypeName),
+        UnqualTypeName = unqualify_name(TypeName),
         MLDS_TypeName = mlds_append_class_qualifier(MLDS_ModuleName,
             module_qual, Globals, UnqualTypeName, TypeArity),
         Name = ml_format_reserved_object_name(CtorName, CtorArity),
@@ -854,7 +854,7 @@
             % If so, append the name of the derived class to the name of the
             % base class for this type (since the derived class will also be
             % nested inside the base class).
-            unqualify_name(CtorSymName, CtorName),
+            CtorName = unqualify_name(CtorSymName),
             QualTypeName = qual(MLDS_Module, _QualKind, TypeName),
             ClassQualifier = mlds_append_class_qualifier(MLDS_Module,
                 module_qual, Globals, TypeName, TypeArity),
@@ -1518,7 +1518,7 @@
             (
                 ConsId = cons(ConsName, ConsArity)
             ->
-                unqualify_name(ConsName, UnqualConsName),
+                UnqualConsName = unqualify_name(ConsName),
                 FieldId = ml_gen_field_id(VarType, Tag, UnqualConsName,
                     ConsArity, FieldName, Globals)
             ;
Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.83
diff -u -b -r1.83 mlds_to_java.m
--- compiler/mlds_to_java.m	22 Aug 2006 05:03:58 -0000	1.83
+++ compiler/mlds_to_java.m	7 Sep 2006 00:47:42 -0000
@@ -1060,7 +1060,7 @@
     output_imports(Imports, !IO),
     io.write_list(ForeignDecls, "\n", output_java_decl(Indent), !IO),
     io.write_string("public class ", !IO),
-    unqualify_name(JavaSafeModuleName, ClassName),
+    ClassName = unqualify_name(JavaSafeModuleName),
     io.write_string(ClassName, !IO),
     io.write_string(" {\n", !IO),
     maybe_write_main_driver(Indent + 1, JavaSafeModuleName, Defns, !IO).
@@ -1096,7 +1096,7 @@
         % Save the progname and command line arguments in the class variables
         % of `mercury.runtime.JavaInternal', as well as setting the default
         % exit status.
-        unqualify_name(JavaSafeModuleName, ClassName),
+        ClassName = unqualify_name(JavaSafeModuleName),
         indent_line(Indent + 1, !IO),
         io.write_string("mercury.runtime.JavaInternal.progname = """, !IO),
         io.write_string(ClassName, !IO),
Index: compiler/mode_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.106
diff -u -b -r1.106 mode_errors.m
--- compiler/mode_errors.m	20 Aug 2006 08:21:19 -0000	1.106
+++ compiler/mode_errors.m	7 Sep 2006 04:58:13 -0000
@@ -164,7 +164,7 @@
     --->    mode_error_info(
                 set(prog_var),      % The variables which caused the error
                                     % (we will attempt to reschedule the goal
-                                    % if the one of these variables becomes
+                                    % if one of these variables becomes
                                     % more instantiated).
                 mode_error,         % The nature of the error.
                 prog_context,       % Where the error occurred.
@@ -190,32 +190,32 @@
 :- pred report_mode_errors(mode_info::in, mode_info::out,
     io::di, io::uo) is det.
 
-    % Print an error message describing a mode error.
+    % If there were any warnings recorded in the mode_info,
+    % report them to the user now.
     %
-:- pred report_mode_error(mode_error::in, mode_info::in,
+:- pred report_mode_warnings(mode_info::in, mode_info::out,
     io::di, io::uo) is det.
 
+    % Initialize the mode_context.
+    %
+:- pred mode_context_init(mode_context::out) is det.
+
+
     % Report an error for a predicate with no mode declarations
     % unless mode inference is enabled and the predicate is local.
+    % XXX This predicate should be included in the types above.
     %
 :- pred maybe_report_error_no_modes(pred_id::in, pred_info::in,
-    module_info::in, io::di, io::uo) is det.
+    module_info::in, module_info::out, io::di, io::uo) is det.
 
-    % If there were any warnings recorded in the mode_info,
-    % report them to the user now.
-    %
-:- pred report_mode_warnings(mode_info::in, mode_info::out,
-    io::di, io::uo) is det.
-
-    % Print a warning message.
+    % Report an error for the case when two mode declarations
+    % declare indistinguishable modes.
+    % XXX This predicate should be included in the types above.
     %
-:- pred report_mode_warning(mode_info::in, mode_warning_info::in,
+:- pred report_indistinguishable_modes_error(proc_id::in, proc_id::in,
+    pred_id::in, pred_info::in, module_info::in, module_info::out,
     io::di, io::uo) is det.
 
-    % Initialize the mode_context.
-    %
-:- pred mode_context_init(mode_context::out) is det.
-
     % Write out the inferred `mode' declarations for a list of pred_ids.
     % The bool indicates whether or not to write out determinism
     % annotations on the modes (it should only be set to `yes' _after_
@@ -224,12 +224,6 @@
 :- pred write_mode_inference_messages(list(pred_id)::in, bool::in,
     module_info::in, io::di, io::uo) is det.
 
-    % Report an error for the case when two mode declarations
-    % declare indistinguishable modes.
-    %
-:- pred report_indistinguishable_modes_error(proc_id::in, proc_id::in,
-    pred_id::in, pred_info::in, module_info::in, io::di, io::uo) is det.
-
 :- pred output_mode_decl(proc_id::in, pred_info::in, io::di, io::uo) is det.
 :- func mode_decl_to_string(proc_id, pred_info) = string.
 
@@ -262,177 +256,204 @@
 :- import_module varset.
 
 %-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
+report_mode_errors(!ModeInfo, !IO) :-
+    mode_info_get_errors(!.ModeInfo, Errors),
+    (
+        Errors = [FirstError | _],
+        % XXX Document exactly why we only report the first.
+        FirstError = mode_error_info(_, ModeError, Context, ModeContext),
+        mode_info_set_context(Context, !ModeInfo),
+        mode_info_set_mode_context(ModeContext, !ModeInfo),
+        report_mode_error(ModeError, !ModeInfo, !IO)
+    ;
+        Errors = []
+    ).
+
+report_mode_warnings(!ModeInfo, !IO) :-
+    mode_info_get_warnings(!.ModeInfo, Warnings),
+    list.foldl2(report_mode_warning, Warnings, !ModeInfo, !IO).
+
+    % Print an error message describing a mode error.
+    %
+:- pred report_mode_error(mode_error::in,
+    mode_info::in, mode_info::out, io::di, io::uo) is det.
+
+report_mode_error(ModeError, !ModeInfo, !IO) :-
+    Spec = mode_error_to_spec(ModeError, !.ModeInfo),
+    write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+    mode_info_get_module_info(!.ModeInfo, ModuleInfo0),
+    module_info_incr_num_errors(NumErrors, ModuleInfo0, ModuleInfo),
+    mode_info_set_module_info(ModuleInfo, !ModeInfo).
+
+    % Print a warning message.
+    %
+:- pred report_mode_warning(mode_warning_info::in,
+    mode_info::in, mode_info::out, io::di, io::uo) is det.
 
-report_mode_error(ModeError, ModeInfo, !IO) :-
-    ExtendedSpecs = mode_error_to_specs(ModeError, ModeInfo),
-    % XXX This module needs some rearrangement for the global extra erro info
-    % flag to be respected properly.  In the meantime we just set it to yes
-    % because that was the original behaviour for this module was.
-    globals.io_set_extra_error_info(yes, !IO),
-    write_extended_error_specs(ExtendedSpecs, !IO).
-
-report_mode_warning(ModeInfo, Warning, !IO) :-
-    Specs = mode_warning_to_specs(ModeInfo, Warning),
-    write_error_specs(Specs, !IO),
-    record_warning(!IO).
+report_mode_warning(Warning, !ModeInfo, !IO) :-
+    Spec = mode_warning_to_spec(!.ModeInfo, Warning),
+    write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+    mode_info_get_module_info(!.ModeInfo, ModuleInfo0),
+    module_info_incr_num_errors(NumErrors, ModuleInfo0, ModuleInfo),
+    mode_info_set_module_info(ModuleInfo, !ModeInfo).
 
-:- func mode_error_to_specs(mode_error::in, mode_info::in)
-    = (list(extended_error_msg_spec)::out(extended_error_msg_specs)) is det.
+%-----------------------------------------------------------------------------%
 
-mode_error_to_specs(ModeError, ModeInfo) = ExtendedSpecs :-
+:- func mode_error_to_spec(mode_error, mode_info) = error_spec.
+
+mode_error_to_spec(ModeError, ModeInfo) = Spec :-
     (
         ModeError = mode_error_disj(MergeContext, ErrorList),
-        Specs = mode_error_disj_to_specs(ModeInfo, MergeContext, ErrorList),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_disj_to_spec(ModeInfo, MergeContext, ErrorList)
     ;
         ModeError = mode_error_par_conj(ErrorList),
-        Specs = mode_error_par_conj_to_specs(ModeInfo, ErrorList),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_par_conj_to_spec(ModeInfo, ErrorList)
     ;
         ModeError = mode_error_higher_order_pred_var(PredOrFunc, Var, Inst,
             Arity),
-        Specs = mode_error_higher_order_pred_var_to_specs(ModeInfo, PredOrFunc,
-            Var, Inst, Arity),
-            extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_higher_order_pred_var_to_spec(ModeInfo, PredOrFunc,
+            Var, Inst, Arity)
     ;
         ModeError = mode_error_poly_unify(Var, Inst),
-        Specs = mode_error_poly_unify_to_specs(ModeInfo, Var, Inst),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_poly_unify_to_spec(ModeInfo, Var, Inst)
     ;
         ModeError = mode_error_var_is_live(Var),
-        Specs = mode_error_var_is_live_to_specs(ModeInfo, Var),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_var_is_live_to_spec(ModeInfo, Var)
     ;
         ModeError = mode_error_var_has_inst(Var, InstA, InstB),
-        Specs = mode_error_var_has_inst_to_specs(ModeInfo, Var, InstA, InstB),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_var_has_inst_to_spec(ModeInfo, Var, InstA, InstB)
     ;
         ModeError = mode_error_unify_pred(Var, RHS, Type, PredOrFunc),
-        Specs = mode_error_unify_pred_to_specs(ModeInfo, Var, RHS, Type,
-            PredOrFunc),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_unify_pred_to_spec(ModeInfo, Var, RHS, Type,
+            PredOrFunc)
     ;
         ModeError = mode_error_implied_mode(Var, InstA, InstB),
-        Specs = mode_error_implied_mode_to_specs(ModeInfo, Var, InstA, InstB),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_implied_mode_to_spec(ModeInfo, Var, InstA, InstB)
     ;
         ModeError = mode_error_no_mode_decl,
-        Specs = mode_error_no_mode_decl_to_specs(ModeInfo),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_no_mode_decl_to_spec(ModeInfo)
     ;
         ModeError = mode_error_bind_var(Reason, Var, InstA, InstB),
-        Specs = mode_error_bind_var_to_specs(ModeInfo, Reason, Var,
-            InstA, InstB),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_bind_var_to_spec(ModeInfo, Reason, Var,
+            InstA, InstB)
     ;
         ModeError = mode_error_non_local_lambda_var(Var, Inst),
-        Specs = mode_error_non_local_lambda_var_to_specs(ModeInfo, Var, Inst),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_non_local_lambda_var_to_spec(ModeInfo, Var, Inst)
     ;
         ModeError = mode_error_unify_var_var(VarA, VarB, InstA, InstB),
-        Specs = mode_error_unify_var_var_to_specs(ModeInfo, VarA, VarB,
-            InstA, InstB),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_unify_var_var_to_spec(ModeInfo, VarA, VarB,
+            InstA, InstB)
     ;
         ModeError = mode_error_unify_var_lambda(VarA, InstA, InstB),
-        Specs = mode_error_unify_var_lambda_to_specs(ModeInfo, VarA,
-            InstA, InstB),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_unify_var_lambda_to_spec(ModeInfo, VarA,
+            InstA, InstB)
     ;
         ModeError = mode_error_unify_var_functor(Var, Name, Args, Inst,
             ArgInsts),
-        Specs = mode_error_unify_var_functor_to_specs(ModeInfo, Var, Name,
-            Args, Inst, ArgInsts),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_unify_var_functor_to_spec(ModeInfo, Var, Name,
+            Args, Inst, ArgInsts)
     ;
         ModeError = mode_error_conj(Errors, Culprit),
-        ExtendedSpecs = mode_error_conj_to_specs(ModeInfo, Errors, Culprit)
+        Spec = mode_error_conj_to_spec(ModeInfo, Errors, Culprit)
     ;
         ModeError = mode_error_no_matching_mode(Vars, Insts),
-        Specs = mode_error_no_matching_mode_to_specs(ModeInfo, Vars, Insts),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_no_matching_mode_to_spec(ModeInfo, Vars, Insts)
     ;
         ModeError = mode_error_in_callee(Vars, Insts,
             CalleePredId, CalleeProcId, CalleeErrors),
-        ExtendedSpecs = mode_error_in_callee_to_specs(ModeInfo, Vars, Insts,
+        Spec = mode_error_in_callee_to_spec(ModeInfo, Vars, Insts,
             CalleePredId, CalleeProcId, CalleeErrors)
     ;
         ModeError = mode_error_final_inst(ArgNum, Var, VarInst, Inst, Reason),
-        Specs = mode_error_final_inst_to_specs(ModeInfo, ArgNum, Var, VarInst,
-            Inst, Reason),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = mode_error_final_inst_to_spec(ModeInfo, ArgNum, Var, VarInst,
+            Inst, Reason)
     ;
         ModeError = purity_error_should_be_in_promise_purity_scope(NegCtxt,
             Var),
-        Specs = purity_error_should_be_in_promise_purity_scope_to_specs(
-            NegCtxt, ModeInfo, Var),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = purity_error_should_be_in_promise_purity_scope_to_spec(NegCtxt,
+            ModeInfo, Var)
     ;
         ModeError = purity_error_lambda_should_be_impure(Vars),
-        Specs = purity_error_lambda_should_be_impure_to_specs(ModeInfo, Vars),
-        extend_specs(Specs, ExtendedSpecs)
+        Spec = purity_error_lambda_should_be_impure_to_spec(ModeInfo, Vars)
     ).
 
-:- func mode_warning_to_specs(mode_info, mode_warning_info)
-    = list(error_msg_spec).
+:- func mode_warning_to_spec(mode_info, mode_warning_info) = error_spec.
 
-mode_warning_to_specs(!.ModeInfo, Warning) = Specs :-
+mode_warning_to_spec(!.ModeInfo, Warning) = Spec :-
     Warning = mode_warning_info(ModeWarning, Context, ModeContext),
     mode_info_set_context(Context, !ModeInfo),
     mode_info_set_mode_context(ModeContext, !ModeInfo),
     (
         ModeWarning = cannot_succeed_var_var(VarA, VarB, InstA, InstB),
-        Specs = mode_warning_cannot_succeed_var_var(!.ModeInfo, VarA, VarB,
+        Spec = mode_warning_cannot_succeed_var_var(!.ModeInfo, VarA, VarB,
             InstA, InstB)
     ;
         ModeWarning = cannot_succeed_var_functor(Var, Inst, ConsId),
-        Specs = mode_warning_cannot_succeed_var_functor(!.ModeInfo,
+        Spec = mode_warning_cannot_succeed_var_functor(!.ModeInfo,
             Var, Inst, ConsId)
     ).
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_conj_to_specs(mode_info::in, list(delayed_goal)::in,
-    schedule_culprit::in)
-    = (list(extended_error_msg_spec)::out(extended_error_msg_specs)) is det.
+:- func mode_error_conj_to_spec(mode_info, list(delayed_goal),
+    schedule_culprit) = error_spec.
 
-mode_error_conj_to_specs(ModeInfo, Errors, Culprit) = Specs :-
+mode_error_conj_to_spec(ModeInfo, Errors, Culprit) = Spec :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    list.filter(is_error_important, Errors, ImportantErrors, OtherErrors),
 
-    % If there's more than one error, and we have verbose-errors enabled,
-    % report them all.
+    (
+        Errors = [],
+        unexpected(this_file, "mode_error_conj_to_spec: no errors")
+    ;
+        Errors = [Error],
+        Msgs1 = mode_error_conjunct_to_msgs(VarSet, Context, ModeInfo, Error)
+    ;
+        Errors = [_, _ | _],
+        % If there's more than one error, we use the setting of
+        % --verbose-errors to decide between reporting just one and
+        % reporting them all. Unfortunately, We can't use the
+        % verbose_and_nonverbose functor of the error_msg_component type
+        % to package up the two cases, because we need to package up
+        % multiple messages, each with its own context.
+        list.filter(is_error_important, Errors, ImportantErrors, OtherErrors),
     mode_info_get_module_info(ModeInfo, ModuleInfo),
     module_info_get_globals(ModuleInfo, Globals),
     globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
     (
+            VerboseErrors = no,
+            % In the absence of --verbose-errors, report only one error.
+            % We prefer that this be an important error.
+            ( ImportantErrors = [FirstImportantError | _] ->
+                ConjMsgs = mode_error_conjunct_to_msgs(VarSet, Context,
+                    ModeInfo, FirstImportantError)
+            ; OtherErrors = [FirstOtherError | _] ->
+                ConjMsgs = mode_error_conjunct_to_msgs(VarSet, Context,
+                    ModeInfo, FirstOtherError)
+            ;
+                unexpected(this_file,
+                    "mode_error_conj_to_spec: no errors of any kind")
+            ),
+            % MoreMsg is there to indicate that --verbose-errors would yield
+            % more information.
+            MoreMsg = simple_msg(Context, [verbose_only([])]),
+            Msgs1 = ConjMsgs ++ [MoreMsg]
+        ;
         VerboseErrors = yes,
-        Errors = [_, _ | _]
-    ->
-        PiecesA = [words("mode error in conjunction. The next"),
+            Preamble = mode_info_context_preamble(ModeInfo),
+            ConjPieces = [words("mode error in conjunction. The next"),
             fixed(int_to_string(list.length(Errors))),
-            words("error messages indicate possible causes of this error.")],
-        Specs1Start = [plain_spec(mode_info_context_to_spec(ModeInfo)),
-            plain_spec(error_msg_spec(no, Context, 0, PiecesA))],
-        Specs1Rest = list.map(
-            mode_error_conjunct_to_specs(VarSet, Context, ModeInfo),
+                words("error messages indicate"),
+                words("possible causes of this error.")],
+            Msgs1Start = [simple_msg(Context,
+                [always(Preamble ++ ConjPieces)])],
+            Msgs1Rest = list.map(
+                mode_error_conjunct_to_msgs(VarSet, Context, ModeInfo),
             ImportantErrors ++ OtherErrors),
-        Specs1 = Specs1Start ++ list.condense(Specs1Rest)
-    ;
-        % In the normal case, only report the first error.
-        ImportantErrors = [FirstImportantError | _]
-    ->
-        Specs1 = mode_error_conjunct_to_specs(VarSet, Context, ModeInfo,
-            FirstImportantError)
-    ;
-        OtherErrors = [FirstOtherError | _]
-    ->
-        Specs1 = mode_error_conjunct_to_specs(VarSet, Context, ModeInfo,
-            FirstOtherError)
-    ;
-        % There wasn't any error to report!  This can't happen.
-        unexpected(this_file, "report_mode_error_conj")
+            Msgs1 = Msgs1Start ++ list.condense(Msgs1Rest)
+        )
     ),
 
     % If the goal(s) couldn't be scheduled because we couldn't reorder things
@@ -440,12 +461,12 @@
     (
         Culprit = conj_floundered,
         % We've already reported everything we can.
-        Specs2 = []
+        Msgs2 = []
     ;
         Culprit = goal_itself_was_impure,
         Pieces = [words("The goal could not be reordered,"),
             words("because it was impure.")],
-        Specs2 = [plain_spec(error_msg_spec(no, Context, 0, Pieces))]
+        Msgs2 = [simple_msg(Context, [always(Pieces)])]
     ;
         Culprit = goals_followed_by_impure_goal(ImpureGoal),
         ImpureGoal = _ - ImpureGoalInfo,
@@ -453,10 +474,12 @@
         Pieces1 = [words("The goal could not be reordered,"),
             words("because it was followed by an impure goal.")],
         Pieces2 = [words("This is the location of the impure goal.")],
-        Specs2 = [plain_spec(error_msg_spec(no, Context, 0, Pieces1)),
-            plain_spec(error_msg_spec(no, ImpureGoalContext, 0, Pieces2))]
+        Msgs2 = [
+            simple_msg(Context, [always(Pieces1)]),
+            simple_msg(ImpureGoalContext, [always(Pieces2)])
+        ]
     ),
-    Specs = Specs1 ++ Specs2.
+    Spec = error_spec(severity_error, phase_mode_check, Msgs1 ++ Msgs2).
 
 :- pred is_error_important(delayed_goal::in) is semidet.
 
@@ -477,39 +500,28 @@
         true
     ).
 
-:- func mode_error_conjunct_to_specs(prog_varset::in, prog_context::in,
-    mode_info::in, delayed_goal::in)
-    = (list(extended_error_msg_spec)::out(extended_error_msg_specs)) is det.
+:- func mode_error_conjunct_to_msgs(prog_varset, prog_context, mode_info,
+    delayed_goal) = list(error_msg).
 
-mode_error_conjunct_to_specs(VarSet, Context, !.ModeInfo, DelayedGoal)
-        = Specs :-
+mode_error_conjunct_to_msgs(VarSet, Context, !.ModeInfo, DelayedGoal) = Msgs :-
     DelayedGoal = delayed_goal(Vars, Error, Goal),
-    mode_info_get_module_info(!.ModeInfo, ModuleInfo),
-    module_info_get_globals(ModuleInfo, Globals),
-    globals.lookup_bool_option(Globals, debug_modes, Debug),
-    (
-        Debug = yes,
         set.to_sorted_list(Vars, VarList),
-        Pieces1 = [words("Floundered goal, waiting on { "),
+    Pieces1 = [words("Floundered goal, waiting on {"),
             words(mercury_vars_to_string(VarList, VarSet, no)),
-            words(" } :"), nl],
-        Specs1 = [plain_spec(error_msg_spec(no, Context, 0, Pieces1))]
-    ;
-        Debug = no,
-        Specs1 = []
-    ),
-    globals.lookup_bool_option(Globals, very_verbose, VeryVerbose),
-    (
-        VeryVerbose = yes,
-        Specs2 = [anything(write_indented_goal(Goal, ModuleInfo, VarSet))]
-    ;
-        VeryVerbose = no,
-        Specs2 = []
-    ),
+        words("}:"), nl],
+    Msg1 = simple_msg(Context,
+        [option_is_set(debug_modes, yes, [always(Pieces1)])]),
+    mode_info_get_module_info(!.ModeInfo, ModuleInfo),
+    Closure = write_indented_goal(Goal, ModuleInfo, VarSet),
+    Msg2 = error_msg(no, no, 0,
+        [option_is_set(very_verbose, yes,
+            [always([nl]), print_anything(Closure)])]),
     Error = mode_error_info(_, ModeError, ErrorContext, ModeContext),
     mode_info_set_context(ErrorContext, !ModeInfo),
     mode_info_set_mode_context(ModeContext, !ModeInfo),
-    Specs = Specs1 ++ Specs2 ++ mode_error_to_specs(ModeError, !.ModeInfo).
+    SubSpec = mode_error_to_spec(ModeError, !.ModeInfo),
+    SubSpec = error_spec(_, _, SubMsgs),
+    Msgs = [Msg1, Msg2] ++ SubMsgs.
 
 :- pred write_indented_goal(hlds_goal::in, module_info::in, prog_varset::in,
     io::di, io::uo) is det.
@@ -520,39 +532,42 @@
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_disj_to_specs(mode_info, merge_context, merge_errors)
-    = list(error_msg_spec).
+:- func mode_error_disj_to_spec(mode_info, merge_context, merge_errors)
+    = error_spec.
 
-mode_error_disj_to_specs(ModeInfo, MergeContext, ErrorList) = Specs :-
+mode_error_disj_to_spec(ModeInfo, MergeContext, ErrorList) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
-    Pieces = [words("mode mismatch in "),
-        words(merge_context_to_string(MergeContext)), suffix(".")],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces) |
-        list.map(merge_error_to_spec(ModeInfo), ErrorList)].
+    MainPieces = [words("mode mismatch in "),
+        words(merge_context_to_string(MergeContext)), suffix("."), nl],
+    MergePieceLists = list.map(merge_error_to_pieces(ModeInfo), ErrorList),
+    list.condense(MergePieceLists, MergePieces),
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context,
+            [always(Preamble ++ MainPieces ++ MergePieces)])]).
 
-:- func mode_error_par_conj_to_specs(mode_info, merge_errors)
-    = list(error_msg_spec).
+:- func mode_error_par_conj_to_spec(mode_info, merge_errors) = error_spec.
 
-mode_error_par_conj_to_specs(ModeInfo, ErrorList) = Specs :-
+mode_error_par_conj_to_spec(ModeInfo, ErrorList) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     Pieces = [words("mode error: mutually exclusive bindings"),
         words("in parallel conjunction."),
         words("(The current implementation does not permit"),
         words("parallel conjunctions to fail.)"), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces) |
-        list.map(merge_error_to_spec(ModeInfo), ErrorList)].
+    MergePieceLists = list.map(merge_error_to_pieces(ModeInfo), ErrorList),
+    list.condense(MergePieceLists, MergePieces),
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context,
+            [always(Preamble ++ Pieces ++ MergePieces)])]).
 
-:- func merge_error_to_spec(mode_info, merge_error) = error_msg_spec.
+:- func merge_error_to_pieces(mode_info, merge_error) = list(format_component).
 
-merge_error_to_spec(ModeInfo, Var - Insts) = Spec :-
-    mode_info_get_context(ModeInfo, Context),
+merge_error_to_pieces(ModeInfo, Var - Insts) = Pieces :-
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [words(add_quotes(mercury_var_to_string(Var, VarSet, no))),
         fixed("::"),
-        words(inst_list_to_string(ModeInfo, Insts)), suffix("."), nl],
-    Spec = error_msg_spec(no, Context, 0, Pieces).
+        words(inst_list_to_string(ModeInfo, Insts)), suffix("."), nl].
 
 :- func merge_context_to_string(merge_context) = string.
 
@@ -561,10 +576,11 @@
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_bind_var_to_specs(mode_info, var_lock_reason,
-    prog_var, mer_inst, mer_inst) = list(error_msg_spec).
+:- func mode_error_bind_var_to_spec(mode_info, var_lock_reason,
+    prog_var, mer_inst, mer_inst) = error_spec.
 
-mode_error_bind_var_to_specs(ModeInfo, Reason, Var, VarInst, Inst) = Specs :-
+mode_error_bind_var_to_spec(ModeInfo, Reason, Var, VarInst, Inst) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     (
@@ -585,60 +601,57 @@
     ;
         Reason = var_lock_par_conj,
         ReasonStr = "attempt to bind a non-local variable" ++
-            "inside more than one parallel conjunct."
+            " inside more than one parallel conjunct."
     ),
-    Pieces1 = [words("scope error:"), words(ReasonStr), nl,
+    MainPieces = [words("scope error:"), words(ReasonStr), nl,
         words("Variable"),
         words(add_quotes(mercury_var_to_string(Var, VarSet, no))),
         words("has instantiatedness"),
         words(add_quotes(inst_to_string(ModeInfo, VarInst))), suffix(","), nl,
         words("expected instantiatedness was"),
         words(add_quotes(inst_to_string(ModeInfo, Inst))), suffix("."), nl],
-    mode_info_get_module_info(ModeInfo, ModuleInfo),
-    module_info_get_globals(ModuleInfo, Globals),
-    globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
-    (
-        VerboseErrors = yes,
         (
             Reason = var_lock_negation,
-            Pieces2 = [words("A negation is only allowed to bind variables"),
+        VerbosePieces =
+            [words("A negation is only allowed to bind variables"),
                 words("which are local to the negation, i.e. those which are"),
                 words("implicitly existentially quantified"),
                 words("inside the scope of the negation."), nl]
         ;
             Reason = var_lock_if_then_else,
-            Pieces2 = [words("The condition of an if-then-else is only"),
+        VerbosePieces =
+            [words("The condition of an if-then-else is only"),
                 words("allowed to bind variables which are local to the"),
                 words("condition or which occur only in the condition"),
                 words("and the `then' part."), nl]
         ;
             Reason = var_lock_lambda(_),
-            Pieces2 = [words("A lambda goal is only allowed to bind"),
+        VerbosePieces =
+            [words("A lambda goal is only allowed to bind"),
                 words("its arguments and variables local to the "),
                 words("lambda expression."), nl]
         ;
             Reason = var_lock_trace_goal,
-            Pieces2 = [words("A trace goal is only allowed to bind variables"),
+        VerbosePieces =
+            [words("A trace goal is only allowed to bind variables"),
                 words("which are local to the trace goal."), nl]
         ;
             Reason = var_lock_par_conj,
-            Pieces2 = [words("A nonlocal variable of a parallel conjunction"),
+        VerbosePieces =
+            [words("A nonlocal variable of a parallel conjunction"),
                 words("may be bound in at most one conjunct."), nl]
-        )
-    ;
-        VerboseErrors = no,
-        % XXX We need to set the extra error flag here.
-        Pieces2 = []
     ),
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context,
+            [always(Preamble ++ MainPieces), verbose_only(VerbosePieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_non_local_lambda_var_to_specs(mode_info, prog_var, mer_inst)
-    = list(error_msg_spec).
+:- func mode_error_non_local_lambda_var_to_spec(mode_info, prog_var, mer_inst)
+    = error_spec.
 
-mode_error_non_local_lambda_var_to_specs(ModeInfo, Var, VarInst) = Specs :-
+mode_error_non_local_lambda_var_to_spec(ModeInfo, Var, VarInst) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [words("mode error: variable"),
@@ -648,39 +661,40 @@
         suffix(","), nl,
         words("expected instantiatedness for non-local variables"),
         words("of lambda goals is `ground'."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_in_callee_to_specs(mode_info::in, list(prog_var)::in,
-    list(mer_inst)::in, pred_id::in, proc_id::in, list(mode_error_info)::in)
-    = (list(extended_error_msg_spec)::out(extended_error_msg_specs)) is det.
+:- func mode_error_in_callee_to_spec(mode_info, list(prog_var), list(mer_inst),
+    pred_id, proc_id, list(mode_error_info)) = error_spec.
 
-mode_error_in_callee_to_specs(!.ModeInfo, Vars, Insts,
-        CalleePredId, CalleeProcId, CalleeModeErrors) = Specs :-
+mode_error_in_callee_to_spec(!.ModeInfo, Vars, Insts,
+        CalleePredId, CalleeProcId, CalleeModeErrors) = Spec :-
+    Preamble = mode_info_context_preamble(!.ModeInfo),
     mode_info_get_module_info(!.ModeInfo, ModuleInfo),
     mode_info_get_context(!.ModeInfo, Context),
     mode_info_get_varset(!.ModeInfo, VarSet),
-    Pieces1 = [words("mode error: arguments"),
+    MainPieces = [words("mode error: arguments"),
         words(add_quotes(mercury_vars_to_string(Vars, VarSet, no))),
         words("have the following insts:"), nl_indent_delta(1)] ++
         inst_list_to_sep_lines(!.ModeInfo, Insts) ++
         [words("which does not match any of the valid modes for")],
-    module_info_get_globals(ModuleInfo, Globals),
-    globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
-    (
-        VerboseErrors = yes,
-        Pieces2 = [words("the callee"), prefix("(")] ++
-            describe_one_pred_name(ModuleInfo, should_module_qualify,
-                CalleePredId) ++ [suffix(")"), nl,
-            words("because of the following error."), nl]
-    ;
-        VerboseErrors = no,
-        Pieces2 = [words("the callee, because of the following error."), nl]
-    ),
-    InitSpecs = [plain_spec(mode_info_context_to_spec(!.ModeInfo)),
-        plain_spec(error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2))],
+
+    CalleePredIdPieces = describe_one_pred_name(ModuleInfo,
+        should_module_qualify, CalleePredId),
+    VerboseCalleePieces = [words("the callee"), prefix("(")] ++
+        CalleePredIdPieces ++
+        [suffix(")"), nl, words("because of the following error."), nl],
+    VerbosePieces = MainPieces ++ VerboseCalleePieces,
+    NonVerboseCalleePieces =
+        [words("the callee, because of the following error."), nl],
+    NonVerbosePieces = MainPieces ++ NonVerboseCalleePieces,
+
+    InitMsg = simple_msg(Context,
+        [always(Preamble),
+        verbose_and_nonverbose(VerbosePieces, NonVerbosePieces)]),
+
     (
         CalleeModeErrors = [First | _],
         First = mode_error_info(_, CalleeModeError,
@@ -689,32 +703,36 @@
         mode_info_set_procid(CalleeProcId, !ModeInfo),
         mode_info_set_context(CalleeContext, !ModeInfo),
         mode_info_set_mode_context(CalleeModeContext, !ModeInfo),
-        LaterSpecs0 = mode_error_to_specs(CalleeModeError, !.ModeInfo),
+        CalleeModeErrorSpec = mode_error_to_spec(CalleeModeError, !.ModeInfo),
+        CalleeModeErrorSpec = error_spec(_, _, LaterMsgs0),
         (
-            LaterSpecs0 = [],
-            LaterSpecs = []
+            LaterMsgs0 = [],
+            LaterMsgs = []
         ;
-            LaterSpecs0 = [LaterSpecsHead0 | LaterSpecsTail],
+            LaterMsgs0 = [LaterHead0 | LaterTail],
             (
-                LaterSpecsHead0 = plain_spec(Spec0),
-                Spec = Spec0 ^ spec_treat_as_first := yes,
-                LaterSpecsHead = plain_spec(Spec)
+                LaterHead0 = simple_msg(LaterContext, Components),
+                LaterHead = error_msg(yes(LaterContext), yes, 0, Components)
             ;
-                LaterSpecsHead0 = anything(_),
-                LaterSpecsHead = LaterSpecsHead0
+                LaterHead0 = error_msg(MaybeLaterContext, _, Indent,
+                    Components),
+                LaterHead = error_msg(MaybeLaterContext, yes, Indent,
+                    Components)
             ),
-            LaterSpecs = [LaterSpecsHead | LaterSpecsTail]
+            LaterMsgs = [LaterHead | LaterTail]
         ),
-        Specs = InitSpecs ++ LaterSpecs
+        Spec = error_spec(severity_error, phase_mode_check,
+            [InitMsg | LaterMsgs])
     ;
         CalleeModeErrors = [],
         unexpected(this_file, "report_mode_error_in_callee: no error")
     ).
 
-:- func mode_error_no_matching_mode_to_specs(mode_info, list(prog_var),
-    list(mer_inst)) = list(error_msg_spec).
+:- func mode_error_no_matching_mode_to_spec(mode_info, list(prog_var),
+    list(mer_inst)) = error_spec.
 
-mode_error_no_matching_mode_to_specs(ModeInfo, Vars, Insts) = Specs :-
+mode_error_no_matching_mode_to_spec(ModeInfo, Vars, Insts) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     mode_info_get_mode_context(ModeInfo, ModeContext),
@@ -730,14 +748,15 @@
         inst_list_to_sep_lines(ModeInfo, Insts) ++
         [words("which does not match any of the modes for"),
         words(CallIdStr), suffix("."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
-:- func mode_error_higher_order_pred_var_to_specs(mode_info, pred_or_func,
-    prog_var, mer_inst, arity) = list(error_msg_spec).
+:- func mode_error_higher_order_pred_var_to_spec(mode_info, pred_or_func,
+    prog_var, mer_inst, arity) = error_spec.
 
-mode_error_higher_order_pred_var_to_specs(ModeInfo, PredOrFunc, Var, VarInst,
-        Arity) = Specs :-
+mode_error_higher_order_pred_var_to_spec(ModeInfo, PredOrFunc, Var, VarInst,
+        Arity) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     (
@@ -755,55 +774,49 @@
         words(add_quotes(inst_to_string(ModeInfo, VarInst))),
         suffix(","), nl,
         words(Expecting), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
-:- func mode_error_poly_unify_to_specs(mode_info, prog_var, mer_inst)
-    = list(error_msg_spec).
+:- func mode_error_poly_unify_to_spec(mode_info, prog_var, mer_inst)
+    = error_spec.
 
-mode_error_poly_unify_to_specs(ModeInfo, Var, VarInst) = Specs :-
+mode_error_poly_unify_to_spec(ModeInfo, Var, VarInst) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    Pieces1 = [words("in polymorphically-typed unification:"), nl,
+    MainPieces = [words("in polymorphically-typed unification:"), nl,
         words("mode error: variable"),
         words(add_quotes(mercury_var_to_string(Var, VarSet, no))),
         words("has instantiatedness"),
         words(add_quotes(inst_to_string(ModeInfo, VarInst))), suffix(","), nl,
         words("expected instantiatedness was `ground' or `any'."), nl],
-    mode_info_get_module_info(ModeInfo, ModuleInfo),
-    module_info_get_globals(ModuleInfo, Globals),
-    globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
-    (
-        VerboseErrors = yes,
-        Pieces2 = [words("When unifying two variables whose type"),
+    VerbosePieces = [words("When unifying two variables whose type"),
             words("will not be known until runtime, the variables must both"),
             words("be ground (or have inst `any'). Unifications of"),
             words("polymorphically-typed variables with partially"),
-            words("instantiated modes are not allowed.")]
-    ;
-        VerboseErrors = no,
-        Pieces2 = []
-    ),
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2)].
+        words("instantiated modes are not allowed.")],
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context,
+            [always(Preamble ++ MainPieces), verbose_only(VerbosePieces)])]).
 
-:- func mode_error_var_is_live_to_specs(mode_info, prog_var)
-    = list(error_msg_spec).
+:- func mode_error_var_is_live_to_spec(mode_info, prog_var) = error_spec.
 
-mode_error_var_is_live_to_specs(ModeInfo, Var) = Specs :-
+mode_error_var_is_live_to_spec(ModeInfo, Var) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [words("unique-mode error: the called procedure"),
         words("would clobber its argument, but variable"),
         words(add_quotes(mercury_var_to_string(Var, VarSet, no))),
         words("is still live."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
-:- func mode_error_var_has_inst_to_specs(mode_info, prog_var,
-    mer_inst, mer_inst) = list(error_msg_spec).
+:- func mode_error_var_has_inst_to_spec(mode_info, prog_var,
+    mer_inst, mer_inst) = error_spec.
 
-mode_error_var_has_inst_to_specs(ModeInfo, Var, VarInst, Inst) = Specs :-
+mode_error_var_has_inst_to_spec(ModeInfo, Var, VarInst, Inst) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [words("mode error: variable"),
@@ -812,20 +825,16 @@
         words(add_quotes(inst_to_string(ModeInfo, VarInst))), suffix(","), nl,
         words("expected instantiatedness was"),
         words(add_quotes(inst_to_string(ModeInfo, Inst))), suffix("."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
-:- func mode_error_implied_mode_to_specs(mode_info, prog_var,
-    mer_inst, mer_inst) = list(error_msg_spec).
+:- func mode_error_implied_mode_to_spec(mode_info, prog_var,
+    mer_inst, mer_inst) = error_spec.
 
-mode_error_implied_mode_to_specs(ModeInfo, Var, VarInst, Inst) = Specs :-
+mode_error_implied_mode_to_spec(ModeInfo, Var, VarInst, Inst) = Spec :-
         % This "error" message is really a "sorry, not implemented" message.
         % We only print the message if we will actually generating code.
-    mode_info_get_module_info(ModeInfo, ModuleInfo),
-    module_info_get_globals(ModuleInfo, Globals),
-    globals.lookup_bool_option(Globals, errorcheck_only, ErrorcheckOnly),
-    (
-        ErrorcheckOnly = no,
+    Preamble = mode_info_context_preamble(ModeInfo),
         mode_info_get_context(ModeInfo, Context),
         mode_info_get_varset(ModeInfo, VarSet),
         Pieces = [words("sorry, implied modes not implemented."), nl,
@@ -837,31 +846,29 @@
             words("expected instantiatedness was"),
             words(add_quotes(inst_to_string(ModeInfo, Inst))),
             suffix("."), nl],
-        Specs = [mode_info_context_to_spec(ModeInfo),
-            error_msg_spec(no, Context, 0, Pieces)]
-    ;
-        ErrorcheckOnly = yes,
-        Specs = []
-    ).
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context,
+            [option_is_set(errorcheck_only, no,
+                [always(Preamble ++ Pieces)])])]).
 
-:- func mode_error_no_mode_decl_to_specs(mode_info::in)
-    = (list(error_msg_spec)::out) is det.
+:- func mode_error_no_mode_decl_to_spec(mode_info) = error_spec.
 
-mode_error_no_mode_decl_to_specs(ModeInfo) = Specs :-
+mode_error_no_mode_decl_to_spec(ModeInfo) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     Pieces = [words("no mode declaration for called predicate."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
-:- func mode_error_unify_pred_to_specs(mode_info, prog_var,
-    mode_error_unify_rhs, mer_type, pred_or_func) = list(error_msg_spec).
+:- func mode_error_unify_pred_to_spec(mode_info, prog_var,
+    mode_error_unify_rhs, mer_type, pred_or_func) = error_spec.
 
-mode_error_unify_pred_to_specs(ModeInfo, X, RHS, Type, PredOrFunc) = Specs :-
+mode_error_unify_pred_to_spec(ModeInfo, X, RHS, Type, PredOrFunc) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     mode_info_get_instvarset(ModeInfo, InstVarSet),
     mode_info_get_module_info(ModeInfo, ModuleInfo),
-    module_info_get_globals(ModuleInfo, Globals),
     (
         RHS = error_at_var(Y),
         RHSStr = mercury_var_to_string(Y, VarSet, no)
@@ -877,17 +884,14 @@
             ++ "] ... )"
     ),
     varset.init(TypeVarSet),
-    Pieces1 = [words("In unification of"),
+    MainPieces = [words("In unification of"),
         words(add_quotes(mercury_var_to_string(X, VarSet, no))),
         words("with"), words(add_quotes(RHSStr)), suffix(":"), nl,
         words("mode error: attempt at higher-order unification."), nl,
         words("Cannot unify two terms of type"),
         words(add_quotes(mercury_type_to_string(TypeVarSet, no, Type))),
         suffix("."), nl],
-    globals.lookup_bool_option(Globals, verbose_errors, VerboseErrors),
-    (
-        VerboseErrors = yes,
-        Pieces2 = [words("Your code is trying to test whether two "),
+    VerbosePieces = [words("Your code is trying to test whether two "),
             words(prog_out.pred_or_func_to_full_str(PredOrFunc) ++ "s"),
             words("are equal, by unifying them."),
             words("In the general case, testing equivalence of"),
@@ -897,21 +901,18 @@
             words("In some cases, you can achieve the same effect by"),
             words("writing an explicit universal quantification, e.g."),
             fixed("`all [X] call(P, X) <=> call(Q, X)',"),
-            words("instead of"),
-            fixed("`P = Q'.")]
-    ;
-        VerboseErrors = no,
-        Pieces2 = []
-    ),
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2)].
+        words("instead of"), fixed("`P = Q'.")],
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context,
+            [always(Preamble ++ MainPieces), verbose_only(VerbosePieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_unify_var_var_to_specs(mode_info, prog_var,
-    prog_var, mer_inst, mer_inst) = list(error_msg_spec).
+:- func mode_error_unify_var_var_to_spec(mode_info, prog_var,
+    prog_var, mer_inst, mer_inst) = error_spec.
 
-mode_error_unify_var_var_to_specs(ModeInfo, X, Y, InstX, InstY) = Specs :-
+mode_error_unify_var_var_to_spec(ModeInfo, X, Y, InstX, InstY) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [words("mode error in unification of"),
@@ -927,15 +928,16 @@
         words(add_quotes(mercury_var_to_string(Y, VarSet, no))),
         words("has instantiatedness"),
         words(add_quotes(inst_to_string(ModeInfo, InstY))), suffix("."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_unify_var_lambda_to_specs(mode_info, prog_var,
-    mer_inst, mer_inst) = list(error_msg_spec).
+:- func mode_error_unify_var_lambda_to_spec(mode_info, prog_var,
+    mer_inst, mer_inst) = error_spec.
 
-mode_error_unify_var_lambda_to_specs(ModeInfo, X, InstX, InstY) = Specs :-
+mode_error_unify_var_lambda_to_spec(ModeInfo, X, InstX, InstY) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [words("mode error in unification of"),
@@ -947,16 +949,17 @@
         words(add_quotes(inst_to_string(ModeInfo, InstX))), suffix(","), nl,
         words("lambda expression has instantiatedness"),
         words(add_quotes(inst_to_string(ModeInfo, InstY))), suffix("."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_unify_var_functor_to_specs(mode_info, prog_var,
-    cons_id, list(prog_var), mer_inst, list(mer_inst)) = list(error_msg_spec).
+:- func mode_error_unify_var_functor_to_spec(mode_info, prog_var,
+    cons_id, list(prog_var), mer_inst, list(mer_inst)) = error_spec.
 
-mode_error_unify_var_functor_to_specs(ModeInfo, X, ConsId, Args,
-        InstX, ArgInsts) = Specs :-
+mode_error_unify_var_functor_to_spec(ModeInfo, X, ConsId, Args,
+        InstX, ArgInsts) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     mode_info_get_module_info(ModeInfo, ModuleInfo),
@@ -986,15 +989,16 @@
             words(add_quotes(mercury_cons_id_to_string(ConsId,
                 does_not_need_brackets))), suffix("."), nl]
     ),
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces1 ++ Pieces2)])]).
 
 %-----------------------------------------------------------------------------%
 
 :- func mode_warning_cannot_succeed_var_var(mode_info,
-    prog_var, prog_var, mer_inst, mer_inst) = list(error_msg_spec).
+    prog_var, prog_var, mer_inst, mer_inst) = error_spec.
 
-mode_warning_cannot_succeed_var_var(ModeInfo, X, Y, InstX, InstY) = Specs :-
+mode_warning_cannot_succeed_var_var(ModeInfo, X, Y, InstX, InstY) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [words("warning: unification of"),
@@ -1008,13 +1012,14 @@
         words(add_quotes(mercury_var_to_string(Y, VarSet, no))),
         words("has instantiatedness"),
         words(add_quotes(inst_to_string(ModeInfo, InstY))), suffix("."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_warning, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
 :- func mode_warning_cannot_succeed_var_functor(mode_info, prog_var, mer_inst,
-    cons_id) = list(error_msg_spec).
+    cons_id) = error_spec.
 
-mode_warning_cannot_succeed_var_functor(ModeInfo, X, InstX, ConsId) = Specs :-
+mode_warning_cannot_succeed_var_functor(ModeInfo, X, InstX, ConsId) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [words("warning: unification of"),
@@ -1025,14 +1030,14 @@
         words(add_quotes(mercury_var_to_string(X, VarSet, no))),
         words("has instantiatedness"),
         words(add_quotes(inst_to_string(ModeInfo, InstX))), suffix("."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_warning, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_info_context_to_spec(mode_info) = error_msg_spec.
+:- func mode_info_context_preamble(mode_info) = list(format_component).
 
-mode_info_context_to_spec(ModeInfo) = Spec :-
+mode_info_context_preamble(ModeInfo) = Pieces :-
     mode_info_get_module_info(ModeInfo, ModuleInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_predid(ModeInfo, PredId),
@@ -1054,7 +1059,7 @@
         words(add_quotes(ModeSubDeclStr)), suffix(":"), nl],
     mode_info_get_mode_context(ModeInfo, ModeContext),
     Pieces2 = mode_context_to_pieces(ModeContext, PredMarkers),
-    Spec = error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2).
+    Pieces = Pieces1 ++ Pieces2.
 
 %-----------------------------------------------------------------------------%
 
@@ -1070,7 +1075,7 @@
         suffix(":"), nl].
 mode_context_to_pieces(mode_context_unify(UnifyContext, _Side), _Markers)
         = Pieces :-
-    hlds_out.unify_context_to_pieces(no, _, UnifyContext, [], Pieces).
+    unify_context_first_to_pieces(no, _, UnifyContext, [], Pieces).
 
 %-----------------------------------------------------------------------------%
 
@@ -1078,11 +1083,12 @@
 
 %-----------------------------------------------------------------------------%
 
-:- func mode_error_final_inst_to_specs(mode_info, int, prog_var,
-    mer_inst, mer_inst, final_inst_error) = list(error_msg_spec).
+:- func mode_error_final_inst_to_spec(mode_info, int, prog_var,
+    mer_inst, mer_inst, final_inst_error) = error_spec.
 
-mode_error_final_inst_to_specs(ModeInfo, ArgNum, Var, VarInst, Inst, Reason)
-        = Specs :-
+mode_error_final_inst_to_spec(ModeInfo, ArgNum, Var, VarInst, Inst, Reason)
+        = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     ( Reason = too_instantiated ->
@@ -1102,16 +1108,17 @@
         words("expected final instantiatedness was"),
         words(add_quotes(inst_to_string(ModeInfo, Inst))),
         suffix("."), nl],
-    Specs = [mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-:- func purity_error_should_be_in_promise_purity_scope_to_specs(
-    negated_context_desc, mode_info, prog_var) = list(error_msg_spec).
+:- func purity_error_should_be_in_promise_purity_scope_to_spec(
+    negated_context_desc, mode_info, prog_var) = error_spec.
 
-purity_error_should_be_in_promise_purity_scope_to_specs(NegCtxtDesc,
-        ModeInfo, Var) = Specs :-
+purity_error_should_be_in_promise_purity_scope_to_spec(NegCtxtDesc,
+        ModeInfo, Var) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     (
@@ -1133,17 +1140,16 @@
             words("has inst any and appears in the body.")
         ]
     ),
-    Specs = [
-        mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)
-    ].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-:- func purity_error_lambda_should_be_impure_to_specs(mode_info,
-    list(prog_var)) = list(error_msg_spec).
+:- func purity_error_lambda_should_be_impure_to_spec(mode_info, list(prog_var))
+    = error_spec.
 
-purity_error_lambda_should_be_impure_to_specs(ModeInfo, Vars) = Specs :-
+purity_error_lambda_should_be_impure_to_spec(ModeInfo, Vars) = Spec :-
+    Preamble = mode_info_context_preamble(ModeInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     Pieces = [
@@ -1153,14 +1159,12 @@
         words(mercury_vars_to_string(Vars, VarSet, no)),
         suffix("."), nl
     ],
-    Specs = [
-        mode_info_context_to_spec(ModeInfo),
-        error_msg_spec(no, Context, 0, Pieces)
-    ].
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(Context, [always(Preamble ++ Pieces)])]).
 
 %-----------------------------------------------------------------------------%
 
-maybe_report_error_no_modes(PredId, PredInfo, ModuleInfo, !IO) :-
+maybe_report_error_no_modes(PredId, PredInfo, !ModuleInfo, !IO) :-
     pred_info_get_import_status(PredInfo, ImportStatus),
     ( ImportStatus = status_local ->
         globals.io_lookup_bool_option(infer_modes, InferModesOpt, !IO),
@@ -1170,27 +1174,27 @@
             InferModesOpt = no,
             io.set_exit_status(1, !IO),
             pred_info_context(PredInfo, Context),
-            Pieces1 = [words("Error: no mode declaration for")] ++
-                describe_one_pred_name(ModuleInfo, should_module_qualify,
+            MainPieces = [words("Error: no mode declaration for")] ++
+                describe_one_pred_name(!.ModuleInfo, should_not_module_qualify,
                     PredId) ++ [suffix("."), nl],
-            globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-            (
-                VerboseErrors = yes,
-                Pieces2 = [words("(Use `--infer-modes'"),
-                    words("to enable mode inference.)"), nl]
-            ;
-                VerboseErrors = no,
-                Pieces2 = []
-            ),
-            write_error_pieces(Context, 0, Pieces1 ++ Pieces2, !IO)
+            VerbosePieces =
+                [words("(Use `--infer-modes' to enable mode inference.)"), nl],
+            Spec = error_spec(severity_error, phase_mode_check,
+                [simple_msg(Context,
+                    [always(MainPieces), verbose_only(VerbosePieces)])]),
+            write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+            module_info_incr_num_errors(NumErrors, !ModuleInfo)
         )
     ;
         io.set_exit_status(1, !IO),
         pred_info_context(PredInfo, Context),
         Pieces = [words("Error: no mode declaration for exported")] ++
-            describe_one_pred_name(ModuleInfo, should_module_qualify, PredId)
+            describe_one_pred_name(!.ModuleInfo, should_module_qualify, PredId)
             ++ [suffix("."), nl],
-        write_error_pieces(Context, 0, Pieces, !IO)
+        Spec = error_spec(severity_error, phase_mode_check,
+            [simple_msg(Context, [always(Pieces)])]),
+        write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+        module_info_incr_num_errors(NumErrors, !ModuleInfo)
     ).
 
 %-----------------------------------------------------------------------------%
@@ -1308,67 +1312,30 @@
     ).
 
 %-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-
-report_mode_errors(!ModeInfo, !IO) :-
-    mode_info_get_errors(!.ModeInfo, Errors),
-    (
-        Errors = [FirstError | _],
-        % XXX Document exactly why we only report the first.
-        FirstError = mode_error_info(_, ModeError, Context, ModeContext),
-        mode_info_set_context(Context, !ModeInfo),
-        mode_info_set_mode_context(ModeContext, !ModeInfo),
-        report_mode_error(ModeError, !.ModeInfo, !IO)
-    ;
-        Errors = []
-    ).
-
-report_mode_warnings(!ModeInfo, !IO) :-
-    mode_info_get_warnings(!.ModeInfo, Warnings),
-    list.foldl(report_mode_warning(!.ModeInfo), Warnings, !IO).
-
-%-----------------------------------------------------------------------------%
 
 report_indistinguishable_modes_error(OldProcId, NewProcId, PredId, PredInfo,
-        ModuleInfo, !IO) :-
-    io.set_exit_status(1, !IO),
-
+        !ModuleInfo, !IO) :-
     pred_info_get_procedures(PredInfo, Procs),
     map.lookup(Procs, OldProcId, OldProcInfo),
     map.lookup(Procs, NewProcId, NewProcInfo),
     proc_info_get_context(OldProcInfo, OldContext),
     proc_info_get_context(NewProcInfo, NewContext),
 
-    Pieces1 = [words("In mode declarations for ")] ++
-        describe_one_pred_name(ModuleInfo, should_module_qualify, PredId)
+    MainPieces = [words("In mode declarations for ")] ++
+        describe_one_pred_name(!.ModuleInfo, should_module_qualify, PredId)
         ++ [suffix(":"), nl, words("error: duplicate mode declaration."), nl],
-    Specs1 = [error_msg_spec(no, NewContext, 0, Pieces1)],
-
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
-        Pieces2 = [words("Modes"),
+    VerbosePieces = [words("Modes"),
             fixed(add_quotes(mode_decl_to_string(OldProcId, PredInfo))),
             words("and"),
             fixed(add_quotes(mode_decl_to_string(NewProcId, PredInfo))),
             words("are indistinguishable.")],
-        Specs2 = [error_msg_spec(no, NewContext, 0, Pieces2)]
-    ;
-        VerboseErrors = no,
-        Specs2 = []
-    ),
-
-    Pieces3 = [words("Here is the conflicting mode declaration.")],
-    Specs3 = [error_msg_spec(no, OldContext, 0, Pieces3)],
-    write_error_specs(Specs1 `do_append` Specs2 `do_append` Specs3, !IO).
-
-:- func do_append(list(T)::in(list_skel(I =< ground)),
-    list(T)::in(list_skel(I =< ground))) =
-    (list(T)::out(list_skel(I =< ground))) is det.
-
-do_append([], L) = L.
-do_append([H | T], L) = [H | NT] :-
-    do_append(T, L) = NT.
+    OldPieces = [words("Here is the conflicting mode declaration.")],
+    Spec = error_spec(severity_error, phase_mode_check,
+        [simple_msg(NewContext,
+            [always(MainPieces), verbose_only(VerbosePieces)]),
+        simple_msg(OldContext, [always(OldPieces)])]),
+    write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+    module_info_incr_num_errors(NumErrors, !ModuleInfo).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.342
diff -u -b -r1.342 modes.m
--- compiler/modes.m	5 Sep 2006 06:21:29 -0000	1.342
+++ compiler/modes.m	7 Sep 2006 04:58:26 -0000
@@ -683,12 +683,11 @@
                 proc_info_get_maybe_declared_argmodes(ProcInfo, yes(_))
             )
         ->
-            % there was at least one declared mode for this
-            % procedure
+            % There was at least one declared mode for this procedure.
             true
         ;
-            % there were no declared modes for this procedure
-            maybe_report_error_no_modes(PredId, PredInfo0, !.ModuleInfo, !IO)
+            % There were no declared modes for this procedure.
+            maybe_report_error_no_modes(PredId, PredInfo0, !ModuleInfo, !IO)
         )
     ;
         WhatToCheck = check_unique_modes
@@ -736,18 +735,14 @@
 
 maybe_modecheck_proc(ProcId, PredId, WhatToCheck, MayChangeCalledProc,
         !ModuleInfo, !Changed, NumErrors, !IO) :-
-        % get the proc_info from the module_info
     module_info_pred_proc_info(!.ModuleInfo, PredId, ProcId,
         _PredInfo0, ProcInfo0),
     ( proc_info_get_can_process(ProcInfo0, no) ->
         NumErrors = 0
     ;
-            % modecheck it
-        do_modecheck_proc(ProcId, PredId, WhatToCheck,
-            MayChangeCalledProc, !ModuleInfo, ProcInfo0, ProcInfo,
-            !Changed, NumErrors, !IO),
+        do_modecheck_proc(ProcId, PredId, WhatToCheck, MayChangeCalledProc,
+            !ModuleInfo, ProcInfo0, ProcInfo, !Changed, NumErrors, !IO),
 
-            % save the proc_info back in the module_info
         module_info_preds(!.ModuleInfo, Preds1),
         map.lookup(Preds1, PredId, PredInfo1),
         pred_info_get_procedures(PredInfo1, Procs1),
@@ -769,7 +764,7 @@
 
 do_modecheck_proc(ProcId, PredId, WhatToCheck, MayChangeCalledProc,
         !ModuleInfo, !ProcInfo, !Changed, NumErrors, !IO) :-
-        % extract the useful fields in the proc_info
+    % Extract the useful fields in the proc_info.
     proc_info_get_headvars(!.ProcInfo, HeadVars),
     proc_info_get_argmodes(!.ProcInfo, ArgModes0),
     proc_info_arglives(!.ProcInfo, !.ModuleInfo, ArgLives0),
@@ -795,8 +790,7 @@
     some [!ModeInfo] (
             % Construct the initial instmap.
         mode_list_get_initial_insts(!.ModuleInfo, ArgModes0, ArgInitialInsts),
-        assoc_list.from_corresponding_lists(HeadVars, ArgInitialInsts,
-            InstAL),
+        assoc_list.from_corresponding_lists(HeadVars, ArgInitialInsts, InstAL),
         instmap.from_assoc_list(InstAL, InstMap0),
 
             % Construct the initial set of live vars:
@@ -947,7 +941,7 @@
         mode_info_get_changed_flag(!.ModeInfo, !:Changed),
         mode_info_get_module_info(!.ModeInfo, !:ModuleInfo),
         mode_info_get_varset(!.ModeInfo, VarSet),
-        % VarTypes may be the same as VarTypes0, since mode checking can
+        % VarTypes may differ from VarTypes0, since mode checking can
         % add new variables (e.g. when handling calls in implied modes).
         mode_info_get_var_types(!.ModeInfo, VarTypes),
         mode_info_get_need_to_requantify(!.ModeInfo, NeedToRequantify),
@@ -1107,10 +1101,10 @@
     (
         InferModes = yes,
         normalise_insts(ModuleInfo, ArgTypes, VarFinalInsts1, VarFinalInsts2),
-        %
-        % make sure we set the final insts of any variables which
+
+        % Make sure we set the final insts of any variables which
         % we assumed were dead to `clobbered'.
-        %
+
         mode_info_get_preds(!.ModeInfo, Preds),
         mode_info_get_predid(!.ModeInfo, PredId),
         map.lookup(Preds, PredId, PredInfo),
@@ -1174,11 +1168,9 @@
         ;
             !:Changed = yes,
             (
-                % If this is a solver type with inst `free'
-                % that should have inst `any' then insert
-                % a call to the appropriate initialisation
-                % predicate.
-                %
+                % If this is a solver type with inst `free' that should have
+                % inst `any' then insert a call to the appropriate
+                % initialisation predicate.
                 inst_match.inst_is_free(ModuleInfo, VarInst),
                 inst_match.inst_is_any(ModuleInfo, Inst),
                 type_util.type_is_solver_type(ModuleInfo, Type)
@@ -1186,23 +1178,21 @@
                 prepend_initialisation_call(Var, Type, VarInst, !Goal,
                     !ModeInfo)
             ;
-                % If we're inferring the mode, then don't
-                % report an error, just set changed to yes
-                % to make sure that we will do another
+                % If we're inferring the mode, then don't report an error,
+                % just set changed to yes to make sure that we will do another
                 % fixpoint pass.
                 InferModes = yes
             ->
                 true
             ;
-                % XXX this might need to be reconsidered now
-                % we have unique modes
+                % XXX This might need to be reconsidered now we have
+                % unique modes.
                 ( inst_matches_initial(VarInst, Inst, Type, ModuleInfo) ->
                     Reason = too_instantiated
                 ; inst_matches_initial(Inst, VarInst, Type, ModuleInfo) ->
                     Reason = not_instantiated_enough
                 ;
-                    % I don't think this can happen.
-                    % But just in case...
+                    % I don't think this can happen. But just in case...
                     Reason = wrongly_instantiated
                 ),
                 set.init(WaitingVars),
@@ -1647,10 +1637,9 @@
     unexpected(this_file, "modecheck_goal_expr: unexpected shorthand").
 
     % If the condition of a negation or if-then-else contains any inst any
-    % non-locals (a potential referential transparency violation)
-    % we need to check that the programmer has recognised the
-    % possibility and placed the if-then-else in a promise_<purity>
-    % scope.
+    % non-locals (a potential referential transparency violation), then
+    % we need to check that the programmer has recognised the possibility
+    % and placed the if-then-else in a promise_<purity> scope.
     %
 :- pred check_no_inst_any_vars(negated_context_desc::in, prog_vars::in,
         instmap::in, instmap::in, mode_info::in, mode_info::out) is det.
@@ -1953,9 +1942,8 @@
     mode_info_get_live_vars(!.ModeInfo, LiveVars1),
     mode_info_add_goals_live_vars(ConjType, Goals0, !ModeInfo),
 
-        % Try to schedule goals without inserting any solver
-        % initialisation calls by setting the mode_info flag
-        % may_initialise_solver_vars to no.
+    % Try to schedule goals without inserting any solver initialisation calls
+    % by setting the mode_info flag may_initialise_solver_vars to no.
     mode_info_set_may_initialise_solver_vars(no, !ModeInfo),
 
     modecheck_conj_list_2(ConjType, Goals0, Goals1,
@@ -1965,8 +1953,8 @@
     delay_info_leave_conj(DelayInfo2, DelayedGoals0, DelayInfo3),
     mode_info_set_delay_info(DelayInfo3, !ModeInfo),
 
-        % Otherwise try scheduling by inserting solver
-        % initialisation calls where necessary.
+    % Otherwise try scheduling by inserting solver initialisation calls
+    % where necessary.
     modecheck_delayed_solver_goals(ConjType, Goals2,
         DelayedGoals0, DelayedGoals, RevImpurityErrors0, RevImpurityErrors,
         !ModeInfo, !IO),
@@ -1980,19 +1968,18 @@
     % We only report impurity errors if there were no other errors.
     (
         DelayedGoals = [],
-        %
-        % report all the impurity errors
-        % (making sure we report the errors in the correct order)
-        %
+
+        % Report all the impurity errors
+        % (making sure we report the errors in the correct order).
         list.reverse(RevImpurityErrors, ImpurityErrors),
         mode_info_get_errors(!.ModeInfo, Errors5),
         list.append(Errors5, ImpurityErrors, Errors6),
         mode_info_set_errors(Errors6, !ModeInfo)
     ;
         DelayedGoals = [FirstDelayedGoal | MoreDelayedGoals],
-        % The variables in the delayed goals should not longer
-        % be considered live (the conjunction itself will
-        % delay, and its nonlocals will be made live).
+        % The variables in the delayed goals should no longer be considered
+        % live (the conjunction itself will delay, and its nonlocals will be
+        % made live).
         mode_info_set_live_vars(LiveVars1, !ModeInfo),
         (
             MoreDelayedGoals = [],
@@ -2010,13 +1997,11 @@
 
 mode_info_add_goals_live_vars(_ConjType, [], !ModeInfo).
 mode_info_add_goals_live_vars(ConjType, [Goal | Goals], !ModeInfo) :-
-    % We add the live vars for the goals in the goal list
-    % in reverse order, because this ensures that in the
-    % common case (where there is no delaying), when we come
-    % to remove the live vars for the first goal
-    % they will have been added last and will thus be
-    % at the start of the list of live vars sets, which
-    % makes them cheaper to remove.
+    % We add the live vars for the goals in the goal list in reverse order,
+    % because this ensures that in the common case (where there is no
+    % delaying), when we come to remove the live vars for the first goal
+    % they will have been added last and will thus be at the start of the list
+    % of live vars sets, which makes them cheaper to remove.
     mode_info_add_goals_live_vars(ConjType, Goals, !ModeInfo),
     (
         % Recurse into conjunctions, in case there are any conjunctions
@@ -2101,10 +2086,9 @@
     mode_info_remove_live_vars(NonLocalVars, !ModeInfo),
     modecheck_goal(Goal0, Goal, !ModeInfo, !IO),
 
-        % Now see whether the goal was successfully scheduled.
-        % If we didn't manage to schedule the goal, then we
-        % restore the original instmap, delay_info and livevars
-        % here, and delay the goal.
+    % Now see whether the goal was successfully scheduled. If we didn't manage
+    % to schedule the goal, then we restore the original instmap, delay_info
+    % and livevars here, and delay the goal.
     mode_info_get_errors(!.ModeInfo, Errors),
     (
         Errors = [FirstErrorInfo | _],
@@ -2112,7 +2096,7 @@
         mode_info_set_instmap(InstMap0, !ModeInfo),
         mode_info_add_live_vars(NonLocalVars, !ModeInfo),
         delay_info_delay_goal(DelayInfo0, FirstErrorInfo, Goal0, DelayInfo1),
-        %  delaying an impure goal is an impurity error
+        %  Delaying an impure goal is an impurity error.
         (
             Impure = yes,
             FirstErrorInfo = mode_error_info(Vars, _, _, _),
@@ -2132,8 +2116,8 @@
         mode_info_get_delay_info(!.ModeInfo, DelayInfo1)
     ),
 
-        % Next, we attempt to wake up any pending goals,
-        % and then continue scheduling the rest of the goal.
+    % Next, we attempt to wake up any pending goals, and then continue
+    % scheduling the rest of the goal.
     delay_info_wakeup_goals(WokenGoals, DelayInfo1, DelayInfo),
     list.append(WokenGoals, Goals0, Goals1),
     (
@@ -2187,16 +2171,13 @@
 
 modecheck_delayed_solver_goals(ConjType, Goals, DelayedGoals0, DelayedGoals,
         !ImpurityErrors, !ModeInfo, !IO) :-
-
         % Try to handle any unscheduled goals by inserting solver
         % initialisation calls, aiming for a deterministic schedule.
-        %
     modecheck_delayed_goals_try_det(ConjType, DelayedGoals0, DelayedGoals1,
         Goals0, !ImpurityErrors, !ModeInfo, !IO),
 
         % Try to handle any unscheduled goals by inserting solver
         % initialisation calls, aiming for *any* workable schedule.
-        %
     modecheck_delayed_goals_eager(ConjType, DelayedGoals1, DelayedGoals,
         Goals1, !ImpurityErrors, !ModeInfo, !IO),
     Goals = Goals0 ++ Goals1.
@@ -2554,14 +2535,12 @@
         !ImpurityErrors, !ModeInfo, !IO) :-
     (
             % There are no unscheduled goals, so we don't need to do anything.
-            %
         DelayedGoals0 = [],
         DelayedGoals  = [],
         Goals         = []
     ;
             % There are some unscheduled goals. See if allowing extra
             % initialisation calls (for a single goal) makes a difference.
-            %
         DelayedGoals0 = [_ | _],
 
         Goals0 = list.map(hlds_goal_from_delayed_goal, DelayedGoals0),
@@ -2580,13 +2559,11 @@
         mode_info_set_delay_info(DelayInfo3, !ModeInfo),
 
             % See if we scheduled any goals.
-            %
         (
             length(DelayedGoals1) < length(DelayedGoals0)
         ->
                 % We scheduled some goals. Keep going until we either
                 % flounder or succeed.
-                %
             modecheck_delayed_goals_eager(ConjType,
                 DelayedGoals1, DelayedGoals, Goals2,
                 !ImpurityErrors, !ModeInfo, !IO),
@@ -2748,9 +2725,8 @@
     % This is used for the functor tests in `switch' statements.
     %
 modecheck_functor_test(Var, ConsId, !ModeInfo) :-
-        % figure out the arity of this constructor,
-        % _including_ any type-infos or typeclass-infos
-        % inserted for existential data types.
+    % Figure out the arity of this constructor, _including_ any type-infos
+    % or typeclass-infos inserted for existential data types.
     mode_info_get_module_info(!.ModeInfo, ModuleInfo),
     mode_info_get_var_types(!.ModeInfo, VarTypes),
     map.lookup(VarTypes, Var, Type),
@@ -2997,7 +2973,7 @@
     ).
 
     % Note that there are two versions of modecheck_set_var_inst,
-    % one with arity 7 (suffixed with _call) and one with arity 5.
+    % one with arity 8 (suffixed with _call) and one with arity 5.
     % The former is used for predicate calls, where we may need
     % to introduce unifications to handle calls to implied modes.
     %
@@ -3102,27 +3078,24 @@
     mode_info_get_var_types(!.ModeInfo, VarTypes0),
     map.lookup(VarTypes0, Var0, VarType),
     (
-        % If the initial inst of the variable matches_final
-        % the initial inst specified in the pred's mode declaration,
-        % then it's not a call to an implied mode, it's an exact
-        % match with a genuine mode.
+        % If the initial inst of the variable matches_final the initial inst
+        % specified in the pred's mode declaration, then it's not a call
+        % to an implied mode, it's an exact match with a genuine mode.
         inst_matches_initial_no_implied_modes(VarInst1, InitialInst,
             VarType, ModuleInfo0)
     ->
         Var = Var0
     ;
-        % This is the implied mode case.
-        % We do not yet handle implied modes for partially
-        % instantiated vars, since that would require
-        % doing a partially instantiated deep copy, and we
-        % don't know how to do that yet.
+        % This is the implied mode case. We do not yet handle implied modes
+        % for partially instantiated vars, since that would require doing
+        % a partially instantiated deep copy, and we don't know how to do
+        % that yet.
 
         InitialInst = any(_),
         inst_is_free(ModuleInfo0, VarInst1)
     ->
-        % This is the simple case of implied `any' modes,
-        % where the declared mode was `any -> ...'
-        % and the argument passed was `free'
+        % This is the simple case of implied `any' modes, where the declared
+        % mode was `any -> ...' and the argument passed was `free'.
 
         Var = Var0,
 
@@ -3232,7 +3205,6 @@
 
         % Get the relevant information for the procedure we are transforming
         % (i.e., the caller).
-        %
     mode_info_get_predid(!.ModeInfo, PredId),
     mode_info_get_procid(!.ModeInfo, ProcId),
     module_info_pred_proc_info(ModuleInfo0, PredId, ProcId, PredInfo0,
@@ -3240,7 +3212,6 @@
     pred_info_get_typevarset(PredInfo0, TVarSet),
 
         % Get the pred_info and proc_info for the procedure we are calling.
-        %
     SymName = qualified(CalleeModuleName, CalleePredName),
     get_pred_id_and_proc_id(is_fully_qualified, SymName, predicate, TVarSet,
         ArgTypes, ModuleInfo0, CalleePredId, CalleeProcId),
@@ -3251,7 +3222,6 @@
         % vartypes from the mode_info, not the proc_info, because new vars may
         % have been introduced during mode analysis (e.g., when adding
         % unifications to handle implied modes).
-        %
     mode_info_get_varset(!.ModeInfo, VarSet0),
     mode_info_get_var_types(!.ModeInfo, VarTypes0),
     proc_info_set_varset(VarSet0, ProcInfo0, ProcInfo1),
@@ -3260,28 +3230,24 @@
         PolyInfo0),
 
         % Create a goal_info for the call.
-        %
     goal_info_init(GoalInfo0),
     goal_info_set_context(Context, GoalInfo0, GoalInfo1),
     goal_info_set_nonlocals(NonLocals, GoalInfo1, GoalInfo2),
     goal_info_set_instmap_delta(InstmapDelta, GoalInfo2, GoalInfo),
 
         % Do the transformation for this call goal.
-        %
     SymName = qualified(CalleeModuleName, CalleePredName),
     polymorphism.process_new_call(CalleePredInfo, CalleeProcInfo,
         CalleePredId, CalleeProcId, ArgVars, not_builtin, CallUnifyContext,
         SymName, GoalInfo, Goal, PolyInfo0, PolyInfo),
 
         % Update the information in the predicate table.
-        %
     polymorphism.poly_info_extract(PolyInfo, PredInfo0, PredInfo,
         ProcInfo2, ProcInfo, ModuleInfo1),
     module_info_set_pred_proc_info(PredId, ProcId, PredInfo, ProcInfo,
         ModuleInfo1, ModuleInfo),
 
         % Update the information in the mode_info.
-        %
     proc_info_get_varset(ProcInfo, VarSet),
     proc_info_get_vartypes(ProcInfo, VarTypes),
     mode_info_set_varset(VarSet, !ModeInfo),
@@ -3467,9 +3433,6 @@
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
-    % Given a list of variables, and a list of livenesses,
-    % select the live variables.
-    %
 get_live_vars([], [], []).
 get_live_vars([_ | _], [], _) :-
     unexpected(this_file, "get_live_vars: length mismatch").
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.145
diff -u -b -r1.145 module_qual.m
--- compiler/module_qual.m	5 Sep 2006 06:21:29 -0000	1.145
+++ compiler/module_qual.m	7 Sep 2006 00:48:04 -0000
@@ -1325,7 +1325,7 @@
     ;
         MatchingModules = [Module],
         % A unique match for this ID.
-        unqualify_name(SymName0, IdName),
+        IdName = unqualify_name(SymName0),
         Id = mq_id(qualified(Module, IdName), Arity),
         mq_info_set_module_used(Module, !Info),
         ItemType = convert_simple_item_type(TypeOfId),
@@ -1838,7 +1838,7 @@
     module_id_set::in, list(module_name)::out) is det.
 
 id_set_search_sym_arity(IdSet, Sym, Arity, Modules, MatchingModules) :-
-    unqualify_name(Sym, UnqualName),
+    UnqualName = unqualify_name(Sym),
     (
         map.search(IdSet, UnqualName - Arity, ImportModules - UseModules)
     ->
@@ -1857,7 +1857,7 @@
             ModuleArity = 0,
             id_set_search_sym_arity(Modules, Module, ModuleArity,
                 Modules, MatchingParentModules),
-            unqualify_name(Module, UnqualModule),
+            UnqualModule = unqualify_name(Module),
             AppendModuleName = (pred(X::in, Y::out) is det :-
                     Y = qualified(X, UnqualModule)
             ),
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.400
diff -u -b -r1.400 modules.m
--- compiler/modules.m	30 Aug 2006 04:46:00 -0000	1.400
+++ compiler/modules.m	7 Sep 2006 00:48:12 -0000
@@ -6147,7 +6147,7 @@
         list.member(Item, Items),
         Item = item_pred_or_func(_, _, _, _, predicate, Name, [_, _],
             WithType, _, _, _, _, _) - _,
-        unqualify_name(Name, "main"),
+        unqualify_name(Name) = "main",
 
         % XXX We should allow `main/2' to be declared using
         % `with_type`, but equivalences haven't been expanded
Index: compiler/pd_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pd_info.m,v
retrieving revision 1.29
diff -u -b -r1.29 pd_info.m
--- compiler/pd_info.m	29 Mar 2006 08:07:13 -0000	1.29
+++ compiler/pd_info.m	7 Sep 2006 00:48:18 -0000
@@ -637,7 +637,7 @@
     module_info_get_name(ModuleInfo0, ModuleName),
     make_pred_name_with_context(ModuleName, "DeforestationIn",
         predicate, PredName, Line, Count, SymName),
-    unqualify_name(SymName, Name),
+    Name = unqualify_name(SymName),
 
     pd_info_get_proc_info(!.PDInfo, ProcInfo),
     pred_info_get_typevarset(PredInfo, TVarSet),
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.305
diff -u -b -r1.305 polymorphism.m
--- compiler/polymorphism.m	22 Aug 2006 05:04:02 -0000	1.305
+++ compiler/polymorphism.m	7 Sep 2006 02:27:42 -0000
@@ -2194,7 +2194,7 @@
         !ExtraGoals, !Info) :-
     ClassId = class_id(ClassName, _ClassArity),
     % First create a variable to hold the new typeclass_info.
-    unqualify_name(ClassName, ClassNameString),
+    ClassNameString = unqualify_name(ClassName),
     new_typeclass_info_var(Constraint, ClassNameString, Var, !Info),
     MaybeVar = yes(Var),
     % Then work out where to extract it from.
@@ -2268,7 +2268,7 @@
 
     ClassId = class_id(ClassName, _Arity),
 
-    unqualify_name(ClassName, ClassNameString),
+    ClassNameString = unqualify_name(ClassName),
     new_typeclass_info_var(Constraint, ClassNameString, BaseVar, !Info),
 
     module_info_get_instance_table(ModuleInfo, InstanceTable),
@@ -2909,8 +2909,8 @@
     ;
         % Make a new variable to contain the dictionary for this typeclass
         % constraint.
-        Constraint = constraint(ClassName0, _ClassTypes),
-        unqualify_name(ClassName0, ClassName),
+        Constraint = constraint(ClassSymName, _ClassTypes),
+        ClassName = unqualify_name(ClassSymName),
         new_typeclass_info_var(Constraint, ClassName, ExtraHeadVar, !Info),
         (
             RecordLocns = do_record_type_info_locns,
Index: compiler/post_typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/post_typecheck.m,v
retrieving revision 1.105
diff -u -b -r1.105 post_typecheck.m
--- compiler/post_typecheck.m	22 Aug 2006 05:04:02 -0000	1.105
+++ compiler/post_typecheck.m	7 Sep 2006 00:49:56 -0000
@@ -494,7 +494,7 @@
     % to any local symbols.
     module_info_pred_info(!.Module, PromiseId, PredInfo),
     ( pred_info_is_exported(PredInfo) ->
-        assertion.in_interface_check(Goal, PredInfo, !Module, !IO)
+        in_interface_check(Goal, PredInfo, !Module, !IO)
     ;
         true
     ).
@@ -550,6 +550,138 @@
 
 %-----------------------------------------------------------------------------%
 
+    % Ensure that an assertion which is defined in an interface doesn't
+    % refer to any constructors, functions and predicates defined in the
+    % implementation of that module.
+    %
+:- pred in_interface_check(hlds_goal::in, pred_info::in,
+    module_info::in, module_info::out, io::di, io::uo) is det.
+
+in_interface_check(plain_call(PredId, _, _, _, _,SymName) - GoalInfo,
+        _PredInfo, !Module, !IO) :-
+    module_info_pred_info(!.Module, PredId, CallPredInfo),
+    pred_info_get_import_status(CallPredInfo, ImportStatus),
+    ( status_defined_in_impl_section(ImportStatus) = yes ->
+        goal_info_get_context(GoalInfo, Context),
+        PredOrFunc = pred_info_is_pred_or_func(CallPredInfo),
+        Arity = pred_info_orig_arity(CallPredInfo),
+        IdPieces = [simple_call(simple_call_id(PredOrFunc, SymName, Arity))],
+        write_assertion_interface_error(Context, IdPieces, !Module, !IO)
+    ;
+        true
+    ).
+in_interface_check(generic_call(_, _, _, _) - _, _, !Module, !IO).
+in_interface_check(unify(Var, RHS, _, _, _) - GoalInfo, PredInfo,
+        !Module, !IO) :-
+    goal_info_get_context(GoalInfo, Context),
+    in_interface_check_unify_rhs(RHS, Var, Context, PredInfo, !Module, !IO).
+in_interface_check(call_foreign_proc(_, PredId, _, _, _, _, _) -
+        GoalInfo, _PredInfo, !Module, !IO) :-
+    module_info_pred_info(!.Module, PredId, PragmaPredInfo),
+    pred_info_get_import_status(PragmaPredInfo, ImportStatus),
+    ( status_defined_in_impl_section(ImportStatus) = yes ->
+        goal_info_get_context(GoalInfo, Context),
+        PredOrFunc = pred_info_is_pred_or_func(PragmaPredInfo),
+        Name = pred_info_name(PragmaPredInfo),
+        SymName = unqualified(Name),
+        Arity = pred_info_orig_arity(PragmaPredInfo),
+        IdPieces = [simple_call(simple_call_id(PredOrFunc, SymName, Arity))],
+        write_assertion_interface_error(Context, IdPieces, !Module, !IO)
+    ;
+        true
+    ).
+in_interface_check(conj(_, Goals) - _, PredInfo, !Module, !IO) :-
+    in_interface_check_list(Goals, PredInfo, !Module, !IO).
+in_interface_check(switch(_, _, _) - _, _, _, _, !IO) :-
+    unexpected(this_file, "in_interface_check: assertion contains switch.").
+in_interface_check(disj(Goals) - _, PredInfo, !Module, !IO) :-
+    in_interface_check_list(Goals, PredInfo, !Module, !IO).
+in_interface_check(negation(Goal) - _, PredInfo, !Module, !IO) :-
+    in_interface_check(Goal, PredInfo, !Module, !IO).
+in_interface_check(scope(_, Goal) - _, PredInfo, !Module, !IO) :-
+    in_interface_check(Goal, PredInfo, !Module, !IO).
+in_interface_check(if_then_else(_, If, Then, Else) - _, PredInfo,
+        !Module, !IO) :-
+    in_interface_check(If, PredInfo, !Module, !IO),
+    in_interface_check(Then, PredInfo, !Module, !IO),
+    in_interface_check(Else, PredInfo, !Module, !IO).
+in_interface_check(shorthand(ShorthandGoal) - _GoalInfo, PredInfo,
+        !Module, !IO) :-
+    in_interface_check_shorthand(ShorthandGoal, PredInfo, !Module, !IO).
+
+:- pred in_interface_check_shorthand(shorthand_goal_expr::in,
+    pred_info::in, module_info::in, module_info::out, io::di, io::uo) is det.
+
+in_interface_check_shorthand(bi_implication(LHS, RHS), PredInfo,
+        !Module, !IO) :-
+    in_interface_check(LHS, PredInfo, !Module, !IO),
+    in_interface_check(RHS, PredInfo, !Module, !IO).
+
+%-----------------------------------------------------------------------------%
+
+:- pred in_interface_check_unify_rhs(unify_rhs::in, prog_var::in,
+    prog_context::in, pred_info::in, module_info::in, module_info::out,
+    io::di, io::uo) is det.
+
+in_interface_check_unify_rhs(rhs_var(_), _, _, _, !Module, !IO).
+in_interface_check_unify_rhs(rhs_functor(ConsId, _, _), Var, Context,
+        PredInfo, !Module, !IO) :-
+    pred_info_clauses_info(PredInfo, ClausesInfo),
+    clauses_info_get_vartypes(ClausesInfo, VarTypes),
+    map.lookup(VarTypes, Var, Type),
+    ( type_to_ctor_and_args(Type, TypeCtor, _) ->
+        module_info_get_type_table(!.Module, Types),
+        map.lookup(Types, TypeCtor, TypeDefn),
+        hlds_data.get_type_defn_status(TypeDefn, TypeStatus),
+        ( status_defined_in_impl_section(TypeStatus) = yes ->
+            ConsIdStr = cons_id_to_string(ConsId),
+            IdPieces = [words("constructor"), quote(ConsIdStr)],
+            write_assertion_interface_error(Context, IdPieces, !Module, !IO)
+        ;
+            true
+        )
+    ;
+        unexpected(this_file,
+            "in_interface_check_unify_rhs: type_to_ctor_and_args failed.")
+    ).
+in_interface_check_unify_rhs(rhs_lambda_goal(_, _, _, _, _, _, _, Goal),
+        _Var, _Context, PredInfo, !Module, !IO) :-
+    in_interface_check(Goal, PredInfo, !Module, !IO).
+
+%-----------------------------------------------------------------------------%
+
+:- pred in_interface_check_list(hlds_goals::in, pred_info::in,
+    module_info::in, module_info::out, io::di, io::uo)is det.
+
+in_interface_check_list([], _, !Module, !IO).
+in_interface_check_list([Goal0 | Goal0s], PredInfo, !Module, !IO) :-
+    in_interface_check(Goal0, PredInfo, !Module, !IO),
+    in_interface_check_list(Goal0s, PredInfo, !Module, !IO).
+
+%-----------------------------------------------------------------------------%
+
+:- pred write_assertion_interface_error(prog_context::in,
+    list(format_component)::in, module_info::in, module_info::out,
+    io::di, io::uo) is det.
+
+write_assertion_interface_error(Context, IdPieces, !ModuleInfo, !IO) :-
+    module_info_get_name(!.ModuleInfo, ModuleName),
+    MainPieces =
+        [words("In interface for module"), sym_name(ModuleName), suffix(":"),
+        nl, words("error: exported promise refers to")] ++ IdPieces ++
+        [words("which is defined in the implementation section of module"),
+        sym_name(ModuleName), suffix("."), nl],
+    VerbosePieces =
+        [words("Either move the promise into the implementation section"),
+        words("or move the definition into the interface."), nl],
+    Msgs = [always(MainPieces), verbose_only(VerbosePieces)],
+    Spec = error_spec(severity_error, phase_type_check,
+        [simple_msg(Context, Msgs)]),
+    write_error_spec(Spec, 0, _NumWarnings, 0, NumErrors, !IO),
+    module_info_incr_num_errors(NumErrors, !ModuleInfo).
+
+%-----------------------------------------------------------------------------%
+
 :- pred check_type_of_main(pred_info::in, io::di, io::uo) is det.
 
 check_type_of_main(PredInfo, !IO) :-
@@ -680,17 +812,17 @@
         true
     ;
         ProcIds = pred_info_procids(!.PredInfo),
-        check_for_indistinguishable_modes(ModuleInfo, PredId,
+        check_for_indistinguishable_modes_in_procs(ModuleInfo, PredId,
             ProcIds, [], !PredInfo, !IO)
     ).
 
-:- pred check_for_indistinguishable_modes(module_info::in, pred_id::in,
-    list(proc_id)::in, list(proc_id)::in, pred_info::in, pred_info::out,
-    io::di, io::uo) is det.
+:- pred check_for_indistinguishable_modes_in_procs(module_info::in,
+    pred_id::in, list(proc_id)::in, list(proc_id)::in,
+    pred_info::in, pred_info::out, io::di, io::uo) is det.
 
-check_for_indistinguishable_modes(_, _, [], _, !PredInfo, !IO).
-check_for_indistinguishable_modes(ModuleInfo, PredId, [ProcId | ProcIds],
-        PrevProcIds, !PredInfo, !IO) :-
+check_for_indistinguishable_modes_in_procs(_, _, [], _, !PredInfo, !IO).
+check_for_indistinguishable_modes_in_procs(ModuleInfo, PredId,
+        [ProcId | ProcIds], PrevProcIds, !PredInfo, !IO) :-
     check_for_indistinguishable_mode(ModuleInfo, PredId, ProcId,
         PrevProcIds, Removed, !PredInfo, !IO),
     (
@@ -700,7 +832,7 @@
         Removed = no,
         PrevProcIds1 = [ProcId | PrevProcIds]
     ),
-    check_for_indistinguishable_modes(ModuleInfo, PredId, ProcIds,
+    check_for_indistinguishable_modes_in_procs(ModuleInfo, PredId, ProcIds,
         PrevProcIds1, !PredInfo, !IO).
 
 :- pred check_for_indistinguishable_mode(module_info::in, pred_id::in,
@@ -728,8 +860,10 @@
                 MakeOptInt = yes
             )
         ->
+            % XXX We shouldn't ignore the updated ModuleInfo, which may
+            % differ from the old one in including an updated error count.
             report_indistinguishable_modes_error(ProcId1,
-                ProcId, PredId, !.PredInfo, ModuleInfo, !IO)
+                ProcId, PredId, !.PredInfo, ModuleInfo, _NewModuleInfo, !IO)
         ;
             true
         ),
@@ -880,7 +1014,7 @@
             type_to_ctor_and_args(TypeOfX, TypeCtorOfX, _),
             TypeCtorOfX = type_ctor(qualified(TypeModule, _), _)
         ->
-            unqualify_name(Name0, Name),
+            Name = unqualify_name(Name0),
             ConsId = cons(qualified(TypeModule, Name), Arity)
         ;
             ConsId = ConsId0
@@ -1229,8 +1363,8 @@
         FieldName, FieldNumber0, FieldNumber) :-
     (
         MaybeArgFieldName = yes(ArgFieldName),
-        unqualify_name(ArgFieldName, UnqualFieldName),
-        unqualify_name(FieldName, UnqualFieldName)
+        UnqualFieldName = unqualify_name(ArgFieldName),
+        UnqualFieldName = unqualify_name(FieldName)
     ->
         FieldNumber = FieldNumber0
     ;
Index: compiler/pred_table.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pred_table.m,v
retrieving revision 1.3
diff -u -b -r1.3 pred_table.m
--- compiler/pred_table.m	29 Mar 2006 08:07:15 -0000	1.3
+++ compiler/pred_table.m	2 Sep 2006 14:40:52 -0000
@@ -236,16 +236,16 @@
     %   NeedQual, PartialQualInfo, PredId, PredTable):
     %
     % Insert PredInfo into PredTable0 and assign it a new pred_id.
-    % You should check beforehand that the pred doesn't already
-    % occur in the table.
+    % You should check beforehand that the pred doesn't already occur
+    % in the table.
     %
-:- pred predicate_table_insert(pred_info::in, need_qualifier::in,
+:- pred predicate_table_insert_qual(pred_info::in, need_qualifier::in,
     partial_qualifier_info::in, pred_id::out,
     predicate_table::in, predicate_table::out) is det.
 
-    % Equivalent to predicate_table_insert/6, except that only the
+    % Equivalent to predicate_table_insert_qual/6, except that only the
     % fully-qualified version of the predicate will be inserted into the
-    % predicate symbol table. This is useful for creating % compiler-generated
+    % predicate symbol table. This is useful for creating compiler-generated
     % predicates which will only ever be accessed via fully-qualified names.
     %
 :- pred predicate_table_insert(pred_info::in, pred_id::out,
@@ -700,8 +700,8 @@
         PredicateTable, !PredIds).
 
 :- pred maybe_filter_pred_ids_matching_module(is_fully_qualified::in,
-    module_name::in, predicate_table::in, list(pred_id)::in,
-    list(pred_id)::out) is det.
+    module_name::in, predicate_table::in,
+    list(pred_id)::in, list(pred_id)::out) is det.
 
 maybe_filter_pred_ids_matching_module(may_be_partially_qualified, _, _,
         !PredIds).
@@ -742,8 +742,7 @@
 predicate_table_search_pf_sym_arity(PredicateTable, IsFullyQualified,
         PredOrFunc, qualified(Module, Name), Arity, PredIdList) :-
     predicate_table_search_pf_m_n_a(PredicateTable,
-        IsFullyQualified, PredOrFunc,
-        Module, Name, Arity, PredIdList).
+        IsFullyQualified, PredOrFunc, Module, Name, Arity, PredIdList).
 predicate_table_search_pf_sym_arity(PredicateTable, may_be_partially_qualified,
         PredOrFunc, unqualified(Name), Arity, PredIdList) :-
     predicate_table_search_pf_name_arity(PredicateTable, PredOrFunc,
@@ -778,7 +777,7 @@
     predicate_table::in, predicate_table::out) is det.
 
 reinsert_for_restrict(PartialQualInfo, Preds, AccessibilityTable, PredId,
-        !Table) :-
+        !PredicateTable) :-
     PredInfo = map.lookup(Preds, PredId),
     Access = map.lookup(AccessibilityTable, PredId),
     Access = access(Unqualified, PartiallyQualified),
@@ -796,8 +795,8 @@
         PartiallyQualified = no,
         MaybeQualInfo = no
     ),
-    predicate_table_insert_2(yes(PredId), PredInfo,
-        NeedQual, MaybeQualInfo, _, !Table).
+    do_predicate_table_insert(yes(PredId), PredInfo, NeedQual, MaybeQualInfo,
+        _, !PredicateTable).
 
 :- pred predicate_table_reset(predicate_table::in, predicate_table::out)
     is det.
@@ -810,21 +809,20 @@
 %-----------------------------------------------------------------------------%
 
 predicate_table_insert(PredInfo, PredId, !PredicateTable) :-
-    predicate_table_insert_2(no, PredInfo, must_be_qualified, no, PredId,
+    do_predicate_table_insert(no, PredInfo, must_be_qualified, no, PredId,
         !PredicateTable).
 
-predicate_table_insert(PredInfo, NeedQual, QualInfo, PredId,
+predicate_table_insert_qual(PredInfo, NeedQual, QualInfo, PredId,
         !PredicateTable) :-
-    predicate_table_insert_2(no, PredInfo, NeedQual, yes(QualInfo), PredId,
+    do_predicate_table_insert(no, PredInfo, NeedQual, yes(QualInfo), PredId,
         !PredicateTable).
 
-:- pred predicate_table_insert_2(maybe(pred_id)::in, pred_info::in,
+:- pred do_predicate_table_insert(maybe(pred_id)::in, pred_info::in,
     need_qualifier::in, maybe(partial_qualifier_info)::in, pred_id::out,
     predicate_table::in, predicate_table::out) is det.
 
-predicate_table_insert_2(MaybePredId, PredInfo, NeedQual, MaybeQualInfo,
+do_predicate_table_insert(MaybePredId, PredInfo, NeedQual, MaybeQualInfo,
         PredId, !PredicateTable) :-
-
     !.PredicateTable = predicate_table(Preds0, NextPredId0, PredIds0,
         AccessibilityTable0,
         Pred_N_Index0, Pred_NA_Index0, Pred_MNA_Index0,
Index: compiler/prog_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_data.m,v
retrieving revision 1.173
diff -u -b -r1.173 prog_data.m
--- compiler/prog_data.m	22 Aug 2006 05:04:03 -0000	1.173
+++ compiler/prog_data.m	6 Sep 2006 03:56:08 -0000
@@ -896,7 +896,8 @@
     % These type equivalences are for the type of program variables
     % and associated structures.
     %
-:- type prog_var_type   --->    prog_var_type.
+:- type prog_var_type
+    --->    prog_var_type.
 :- type prog_var    ==  var(prog_var_type).
 :- type prog_varset ==  varset(prog_var_type).
 :- type prog_substitution ==    substitution(prog_var_type).
Index: compiler/prog_io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io.m,v
retrieving revision 1.271
diff -u -b -r1.271 prog_io.m
--- compiler/prog_io.m	30 Aug 2006 04:46:00 -0000	1.271
+++ compiler/prog_io.m	7 Sep 2006 00:50:07 -0000
@@ -4114,7 +4114,7 @@
                 "does not match preceding `:- module' declaration",
             Result = error1([Msg - Term])
         ;
-            unqualify_name(SymName, UnqualName),
+            UnqualName = unqualify_name(SymName),
             Result = ok1(qualified(DefaultModName, UnqualName))
         )
     ;
@@ -4144,7 +4144,7 @@
                 "preceding `:- module' declaration",
             Result = error2([ErrorMsg - ErrorTerm])
         ;
-            unqualify_name(SymName, UnqualName),
+            UnqualName = unqualify_name(SymName),
             Result = ok2(qualified(DefaultModName, UnqualName), Args)
         )
     ;
Index: compiler/prog_io_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
retrieving revision 1.112
diff -u -b -r1.112 prog_io_pragma.m
--- compiler/prog_io_pragma.m	22 Aug 2006 05:04:04 -0000	1.112
+++ compiler/prog_io_pragma.m	7 Sep 2006 00:50:16 -0000
@@ -1002,7 +1002,7 @@
                     SpecializedName = SpecializedName0
                 ;
                     MaybeName = no,
-                    unqualify_name(PredName, UnqualName),
+                    UnqualName = unqualify_name(PredName),
                     make_pred_name(ModuleName, "TypeSpecOf", MaybePredOrFunc,
                         UnqualName, newpred_type_subst(TVarSet, TypeSubn),
                         SpecializedName)
Index: compiler/prog_io_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_util.m,v
retrieving revision 1.51
diff -u -b -r1.51 prog_io_util.m
--- compiler/prog_io_util.m	22 Aug 2006 05:04:04 -0000	1.51
+++ compiler/prog_io_util.m	7 Sep 2006 00:50:21 -0000
@@ -606,7 +606,7 @@
             % If the term is qualified with the `builtin' module
             % then it may be one of the simple builtin insts.
             % We call convert_inst recursively to check for this.
-            unqualify_name(QualifiedName, UnqualifiedName),
+            UnqualifiedName = unqualify_name(QualifiedName),
             convert_simple_builtin_inst(UnqualifiedName, Args1, Result0),
 
             % However, if the inst is a user_inst defined inside
Index: compiler/prog_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_out.m,v
retrieving revision 1.75
diff -u -b -r1.75 prog_out.m
--- compiler/prog_out.m	22 Aug 2006 05:04:05 -0000	1.75
+++ compiler/prog_out.m	7 Sep 2006 00:50:27 -0000
@@ -160,6 +160,7 @@
 
 :- import_module libs.compiler_util.
 :- import_module mdbcomp.prim_data.
+:- import_module parse_tree.error_util.
 :- import_module parse_tree.prog_util.
 
 :- import_module int.
@@ -275,34 +276,30 @@
     Str = simple_call_id_to_string(PredOrFunc, Name, Arity),
     io.write_string(Str, !IO).
 
-write_simple_call_id(PredOrFunc, Name, Arity, !IO) :-
-    Str = simple_call_id_to_string(PredOrFunc, Name, Arity),
+write_simple_call_id(PredOrFunc, SymName, Arity, !IO) :-
+    Str = simple_call_id_to_string(PredOrFunc, SymName, Arity),
     io.write_string(Str, !IO).
 
-simple_call_id_to_string(simple_call_id(PredOrFunc, Name, Arity)) =
-    simple_call_id_to_string(PredOrFunc, Name, Arity).
+simple_call_id_to_string(simple_call_id(PredOrFunc, SymName, Arity)) =
+    simple_call_id_to_string(PredOrFunc, SymName, Arity).
 
-simple_call_id_to_string(PredOrFunc, Name/Arity) =
-    simple_call_id_to_string(PredOrFunc, Name, Arity).
+simple_call_id_to_string(PredOrFunc, SymName/Arity) =
+    simple_call_id_to_string(PredOrFunc, SymName, Arity).
 
-simple_call_id_to_string(PredOrFunc, Name, Arity) = Str :-
+simple_call_id_to_string(PredOrFunc, SymName, Arity) = Str :-
     % XXX When printed, promises are differentiated from predicates or
     % functions by module name, so the module names `promise',
     % `promise_exclusive', etc. should be reserved, and their dummy
     % predicates should have more unusual module names.
-    (
-        Name = unqualified(StrName)
-    ;
-        Name = qualified(_, StrName)
-    ),
+    Name = unqualify_name(SymName),
     % Is it really a promise?
-    ( string.prefix(StrName, "promise__") ->
+    ( string.prefix(Name, "promise__") ->
         MaybePromise = yes(true)
-    ; string.prefix(StrName, "promise_exclusive__") ->
+    ; string.prefix(Name, "promise_exclusive__") ->
         MaybePromise = yes(exclusive)
-    ; string.prefix(StrName, "promise_exhaustive__") ->
+    ; string.prefix(Name, "promise_exhaustive__") ->
         MaybePromise = yes(exhaustive)
-    ; string.prefix(StrName, "promise_exclusive_exhaustive__") ->
+    ; string.prefix(Name, "promise_exclusive_exhaustive__") ->
         MaybePromise = yes(exclusive_exhaustive)
     ;
         MaybePromise = no   % No, it is really a pred or func.
@@ -313,11 +310,12 @@
         Str = "`" ++ PromiseStr ++ "' declaration"
     ;
         MaybePromise = no,
-        PredOrFuncStr = pred_or_func_to_full_str(PredOrFunc),
-        SimpleCallId = simple_call_id(PredOrFunc, Name, Arity),
-        simple_call_id_to_sym_name_and_arity(SimpleCallId, SymArity),
-        SymArityStr = sym_name_and_arity_to_string(SymArity),
-        Str = PredOrFuncStr ++ " `" ++ SymArityStr ++ "'"
+        SimpleCallId = simple_call_id(PredOrFunc, SymName, Arity),
+        simple_call_id_to_sym_name_and_arity(SimpleCallId,
+            AdjustedSymNameAndArity),
+        Pieces = [p_or_f(PredOrFunc),
+            sym_name_and_arity(AdjustedSymNameAndArity)],
+        Str = error_pieces_to_string(Pieces)
     ).
 
 simple_call_id_to_sym_name_and_arity(SimpleCallId, SymName / OrigArity) :-
Index: compiler/prog_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_type.m,v
retrieving revision 1.25
diff -u -b -r1.25 prog_type.m
--- compiler/prog_type.m	22 Aug 2006 05:04:05 -0000	1.25
+++ compiler/prog_type.m	7 Sep 2006 00:51:04 -0000
@@ -898,7 +898,7 @@
         type_to_ctor_and_args(Type, TypeCtor, _),
         TypeCtor = type_ctor(qualified(TypeModule, _), _)
     ->
-        unqualify_name(Name0, UnqualName),
+        UnqualName = unqualify_name(Name0),
         Name = qualified(TypeModule, UnqualName),
         ConsId = cons(Name, OrigArity),
         InstConsId = ConsId
@@ -927,7 +927,7 @@
     % that it's not worth the implementation effort.
     Ctor \= unqualified("{}"),
 
-    map_maybe(unqualify_name, MaybeArgName0, MaybeArgName).
+    MaybeArgName = map_maybe(unqualify_name, MaybeArgName0).
 
 type_constructors_are_type_info(Ctors) :-
     type_is_single_ctor_single_arg(Ctors, Ctor, _, _),
Index: compiler/prog_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_util.m,v
retrieving revision 1.94
diff -u -b -r1.94 prog_util.m
--- compiler/prog_util.m	5 Sep 2006 06:21:30 -0000	1.94
+++ compiler/prog_util.m	7 Sep 2006 00:34:17 -0000
@@ -30,9 +30,9 @@
 
     % Given a symbol name, return its unqualified name.
     %
-:- pred unqualify_name(sym_name::in, string::out) is det.
+:- func unqualify_name(sym_name) = string.
 
-    % sym_name_get_module_name(SymName, ModName):
+    % sym_name_get_module_name(SymName) = ModName:
     %
     % Given a symbol name, return the module qualifiers(s).
     % Fails if the symbol is unqualified.
@@ -294,8 +294,8 @@
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
-unqualify_name(unqualified(PredName), PredName).
-unqualify_name(qualified(_ModuleName, PredName), PredName).
+unqualify_name(unqualified(Name)) = Name.
+unqualify_name(qualified(_ModuleName, Name)) = Name.
 
 sym_name_get_module_name(unqualified(_), _) :- fail.
 sym_name_get_module_name(qualified(ModuleName, _), ModuleName).
Index: compiler/pseudo_type_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pseudo_type_info.m,v
retrieving revision 1.25
diff -u -b -r1.25 pseudo_type_info.m
--- compiler/pseudo_type_info.m	22 Aug 2006 05:04:05 -0000	1.25
+++ compiler/pseudo_type_info.m	7 Sep 2006 00:51:17 -0000
@@ -97,7 +97,7 @@
             PseudoTypeInfo = var_arity_pseudo_type_info(VarArityId, PseudoArgs)
         ;
             TypeCtor = type_ctor(QualTypeName, Arity),
-            unqualify_name(QualTypeName, TypeName),
+            TypeName = unqualify_name(QualTypeName),
             sym_name_get_module_name(QualTypeName, unqualified("builtin"),
                 TypeModule),
             RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName, Arity),
@@ -163,7 +163,7 @@
             TypeInfo = var_arity_type_info(VarArityId, TypeInfoArgs)
         ;
             TypeCtor = type_ctor(QualTypeName, Arity),
-            unqualify_name(QualTypeName, TypeName),
+            TypeName = unqualify_name(QualTypeName),
             sym_name_get_module_name(QualTypeName, unqualified("builtin"),
                 TypeModule),
             RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName, Arity),
Index: compiler/recompilation.check.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.check.m,v
retrieving revision 1.33
diff -u -b -r1.33 recompilation.check.m
--- compiler/recompilation.check.m	30 Aug 2006 04:46:01 -0000	1.33
+++ compiler/recompilation.check.m	7 Sep 2006 00:52:02 -0000
@@ -423,7 +423,7 @@
         Term = term.functor(term.atom("-"), [NameArityTerm, MatchesTerm], _),
         parse_name_and_arity(NameArityTerm, SymName, Arity)
     ->
-        unqualify_name(SymName, Name),
+        Name = unqualify_name(SymName),
         conjunction_to_list(MatchesTerm, MatchTermList),
         list.foldl(parse_simple_item_match(Info), MatchTermList,
             map.init, Matches),
@@ -916,7 +916,7 @@
 
 item_is_new_or_changed(UsedFileTimestamp, UsedVersionNumbers,
         ItemType, SymName, Arity) :-
-    unqualify_name(SymName, Name),
+    Name = unqualify_name(SymName),
     (
         map.search(extract_ids(UsedVersionNumbers, ItemType), Name - Arity,
             UsedVersionNumber)
@@ -941,7 +941,7 @@
         NeedsCheck = yes,
         UsedItems = !.Info ^ used_items,
         UsedItemMap = extract_simple_item_set(UsedItems, ItemType),
-        unqualify_name(SymName, Name),
+        Name = unqualify_name(SymName),
         (
             map.search(UsedItemMap, Name - Arity,
                 MatchingQualifiers)
@@ -963,7 +963,7 @@
 
 check_for_simple_item_ambiguity_2(ItemType, NeedQualifier, SymName, Arity,
         OldModuleQualifier, OldMatchingModuleName, !Info) :-
-    unqualify_name(SymName, Name),
+    Name = unqualify_name(SymName),
     (
         % XXX This is a bit conservative in the case of partially qualified
         % names but that hopefully won't come up too often.
@@ -1009,7 +1009,7 @@
     ->
         UsedItems = !.Info ^ used_items,
         UsedItemMap = extract_pred_or_func_set(UsedItems, ItemType),
-        unqualify_name(SymName, Name),
+        Name = unqualify_name(SymName),
         ( map.search(UsedItemMap, Name, MatchingArityList) ->
             list.foldl(check_for_pred_or_func_item_ambiguity_1(WithType,
                 ItemType, NeedQualifier, SymName, Arity), MatchingArityList,
@@ -1070,7 +1070,7 @@
 
 check_for_pred_or_func_item_ambiguity_2(ItemType, NeedQualifier,
         SymName, Arity, OldModuleQualifier, OldMatchingModuleNames, !Info) :-
-    unqualify_name(SymName, Name),
+    Name = unqualify_name(SymName),
     (
         % XXX This is a bit conservative in the case of partially qualified
         % names but that hopefully won't come up too often.
@@ -1163,7 +1163,7 @@
 check_functor_ambiguities(NeedQualifier, Name, MatchArity, ResolvedCtor,
         !Info) :-
     UsedItems = !.Info ^ used_items,
-    unqualify_name(Name, UnqualName),
+    UnqualName = unqualify_name(Name),
     UsedCtors = UsedItems ^ functors,
     ( map.search(UsedCtors, UnqualName, UsedCtorAL) ->
         check_functor_ambiguities_2(NeedQualifier, Name, MatchArity,
@@ -1237,7 +1237,7 @@
     ->
         true
     ;
-        unqualify_name(SymName, Name),
+        Name = unqualify_name(SymName),
         OldName = module_qualify_name(OldModuleQualifier, Name),
         match_sym_name(OldName, SymName),
         \+ set.member(ResolvedCtor, OldResolvedCtors)
@@ -1363,9 +1363,8 @@
 
 write_recompile_reason(ModuleName, Reason, !IO) :-
     recompile_reason_message(Reason, MaybeContext, ErrorPieces0),
-    ErrorPieces = [words("Recompiling module"),
-        words(string.append(describe_sym_name(ModuleName), ":")), nl
-        | ErrorPieces0],
+    ErrorPieces = [words("Recompiling module"), sym_name(ModuleName),
+        suffix(":"), nl | ErrorPieces0],
     write_error_pieces_maybe_with_context(MaybeContext, 0, ErrorPieces, !IO).
 
 :- pred recompile_reason_message(recompile_reason::in, maybe(context)::out,
@@ -1402,9 +1401,9 @@
         no,
         [
         words("an instance for class"),
-        words(describe_sym_name_and_arity(ClassName / ClassArity)),
+        sym_name_and_arity(ClassName / ClassArity),
         words("in module"),
-        words(describe_sym_name(ModuleName)),
+        sym_name(ModuleName),
         words("was added or modified.")
         ]).
 recompile_reason_message(
@@ -1412,9 +1411,9 @@
         no,
         [
         words("an instance for class "),
-        words(describe_sym_name_and_arity(ClassName / ClassArity)),
+        sym_name_and_arity(ClassName / ClassArity),
         words("in module"),
-        words(describe_sym_name(ModuleName)),
+        sym_name(ModuleName),
         words("was removed.")
         ]).
 
@@ -1422,17 +1421,13 @@
 
 describe_item(item_id(ItemType0, item_name(SymName, Arity))) = Pieces :-
     ( body_item(ItemType0, ItemType1) ->
-        ItemType = ItemType1,
-        BodyWords = "body of "
+        string_to_item_type(ItemTypeStr, ItemType1),
+        ItemPieces = [words("body of"), words(ItemTypeStr)]
     ;
-        ItemType = ItemType0,
-        BodyWords = ""
+        string_to_item_type(ItemTypeStr, ItemType0),
+        ItemPieces = [words(ItemTypeStr)]
     ),
-    string_to_item_type(ItemTypeStr, ItemType),
-    Pieces = [
-        words(string.append(BodyWords, ItemTypeStr)),
-        words(describe_sym_name_and_arity(SymName / Arity))
-        ].
+    Pieces = ItemPieces ++ [sym_name_and_arity(SymName / Arity)].
 
 :- pred body_item(item_type::in, item_type::out) is semidet.
 
@@ -1444,7 +1439,7 @@
 describe_functor(SymName, _Arity, ResolvedFunctor) = Pieces :-
     ResolvedFunctor = pred_or_func(_, ModuleName, PredOrFunc, PredArity),
     string_to_item_type(ItemTypeStr, pred_or_func_to_item_type(PredOrFunc)),
-    unqualify_name(SymName, UnqualName),
+    UnqualName = unqualify_name(SymName),
     SymNameAndArityPiece =
         sym_name_and_arity(qualified(ModuleName, UnqualName) / PredArity),
     Pieces = [words(ItemTypeStr), SymNameAndArityPiece].
Index: compiler/recompilation.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.m,v
retrieving revision 1.24
diff -u -b -r1.24 recompilation.m
--- compiler/recompilation.m	31 Jul 2006 08:31:58 -0000	1.24
+++ compiler/recompilation.m	7 Sep 2006 00:52:09 -0000
@@ -423,7 +423,7 @@
     ;
         ItemSet0 = !.Info ^ used_items,
         IdSet0 = extract_ids(ItemSet0, ItemType),
-        unqualify_name(QualifiedName, UnqualifiedName),
+        UnqualifiedName = unqualify_name(QualifiedName),
         ModuleName = find_module_qualifier(QualifiedName),
         UnqualifiedId = UnqualifiedName - Arity,
         Id = item_name(SymName, _),
Index: compiler/recompilation.usage.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.usage.m,v
retrieving revision 1.37
diff -u -b -r1.37 recompilation.usage.m
--- compiler/recompilation.usage.m	20 Aug 2006 08:21:28 -0000	1.37
+++ compiler/recompilation.usage.m	7 Sep 2006 00:52:22 -0000
@@ -672,7 +672,7 @@
             ),
             MatchingPredIds)),
         svmap.det_insert(ModuleQualifier, PredModules, !MatchingNames),
-        unqualify_name(SymName, Name),
+        Name = unqualify_name(SymName),
         set.fold(find_items_used_by_pred(PredOrFunc, Name - Arity),
             PredModules, !Info)
     ;
@@ -702,7 +702,7 @@
     ModuleInfo = !.Info ^ module_info,
 
     find_matching_functors(ModuleInfo, SymName, Arity, MatchingCtors),
-    unqualify_name(SymName, Name),
+    Name = unqualify_name(SymName),
     set.fold(find_items_used_by_functor(Name, Arity), MatchingCtors, !Info),
 
     ( set.empty(MatchingCtors) ->
@@ -818,7 +818,7 @@
     recompilation_usage_info::in, recompilation_usage_info::out) is det.
 
 record_resolved_item(SymName, Arity, RecordItem, !IdSet, !Info) :-
-    unqualify_name(SymName, UnqualifiedName),
+    UnqualifiedName = unqualify_name(SymName),
     ModuleQualifier = find_module_qualifier(SymName),
     ( map.search(!.IdSet, UnqualifiedName, MatchingNames0) ->
         MatchingNames1 = MatchingNames0
Index: compiler/recompilation.version.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.version.m,v
retrieving revision 1.53
diff -u -b -r1.53 recompilation.version.m
--- compiler/recompilation.version.m	30 Aug 2006 04:46:01 -0000	1.53
+++ compiler/recompilation.version.m	7 Sep 2006 00:52:27 -0000
@@ -368,7 +368,7 @@
         !GatheredItems) :-
     ItemId = item_id(ItemType, ItemName),
     ItemName = item_name(SymName, Arity),
-    unqualify_name(SymName, Name),
+    Name = unqualify_name(SymName),
     IdMap0 = extract_ids(!.GatheredItems, ItemType),
     NameArity = Name - Arity,
     ( map.search(IdMap0, NameArity, MatchingItems0) ->
Index: compiler/type_ctor_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_ctor_info.m,v
retrieving revision 1.81
diff -u -b -r1.81 type_ctor_info.m
--- compiler/type_ctor_info.m	22 Aug 2006 05:04:11 -0000	1.81
+++ compiler/type_ctor_info.m	7 Sep 2006 00:52:45 -0000
@@ -549,7 +549,7 @@
 
 make_notag_details(TypeArity, SymName, ArgType, MaybeArgName, EqualityAxioms,
         Details) :-
-    unqualify_name(SymName, FunctorName),
+    FunctorName = unqualify_name(SymName),
     NumUnivTvars = TypeArity,
     % There can be no existentially typed args to the functor in a notag type.
     ExistTvars = [],
@@ -612,7 +612,7 @@
     map.lookup(ConsTagMap, ConsId, ConsTag),
     expect(unify(ConsTag, int_tag(NextOrdinal0)), this_file,
         "mismatch on constant assigned to functor in enum"),
-    unqualify_name(SymName, FunctorName),
+    FunctorName = unqualify_name(SymName),
     EnumFunctor = enum_functor(FunctorName, NextOrdinal0),
     make_enum_functors(Functors, NextOrdinal0 + 1, ConsTagMap, EnumFunctors).
 
@@ -696,7 +696,7 @@
         TypeArity, ModuleInfo, [MaybeResFunctor | MaybeResFunctors]) :-
     Functor = ctor(ExistTvars, Constraints, SymName, ConstructorArgs),
     list.length(ConstructorArgs, Arity),
-    unqualify_name(SymName, FunctorName),
+    FunctorName = unqualify_name(SymName),
     ConsId = make_cons_id_from_qualified_sym_name(SymName, ConstructorArgs),
     map.lookup(ConsTagMap, ConsId, ConsTag),
     process_cons_tag(ConsTag, ConsRep),
@@ -776,7 +776,7 @@
     ConstructorArg = MaybeArgSymName - ArgType,
     (
         MaybeArgSymName = yes(SymName),
-        unqualify_name(SymName, ArgName),
+        ArgName = unqualify_name(SymName),
         MaybeArgName = yes(ArgName)
     ;
         MaybeArgSymName = no,
Index: compiler/type_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_util.m,v
retrieving revision 1.168
diff -u -b -r1.168 type_util.m
--- compiler/type_util.m	20 Aug 2006 08:21:33 -0000	1.168
+++ compiler/type_util.m	7 Sep 2006 00:53:40 -0000
@@ -322,11 +322,11 @@
 
 %-----------------------------------------------------------------------------%
 
-type_ctor_module(_ModuleInfo, type_ctor(TypeName, _Arity)) = ModuleName :-
-    sym_name_get_module_name(TypeName, unqualified(""), ModuleName).
+type_ctor_module(_ModuleInfo, type_ctor(TypeSymName, _Arity)) = ModuleName :-
+    sym_name_get_module_name(TypeSymName, unqualified(""), ModuleName).
 
-type_ctor_name(_ModuleInfo, type_ctor(Name0, _Arity)) = Name :-
-    unqualify_name(Name0, Name).
+type_ctor_name(_ModuleInfo, type_ctor(TypeSymName, _Arity)) =
+    unqualify_name(TypeSymName).
 
 type_ctor_arity(_ModuleInfo, type_ctor(_Name, Arity)) = Arity.
 
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.402
diff -u -b -r1.402 typecheck.m
--- compiler/typecheck.m	5 Sep 2006 06:21:32 -0000	1.402
+++ compiler/typecheck.m	7 Sep 2006 00:53:45 -0000
@@ -174,7 +174,7 @@
         MaxIterations, !IO),
     typecheck_to_fixpoint(1, MaxIterations, PredIds, !Module,
         FoundError, ExceededIterationLimit, !IO),
-    write_inference_messages(PredIds, !.Module, !IO).
+    write_type_inference_messages(PredIds, !.Module, !IO).
 
     % Repeatedly typecheck the code for a group of predicates
     % until a fixpoint is reached, or until some errors are detected.
@@ -198,7 +198,7 @@
         globals.io_lookup_bool_option(debug_types, DebugTypes, !IO),
         (
             DebugTypes = yes,
-            write_inference_messages(PredIds, !.Module, !IO)
+            write_type_inference_messages(PredIds, !.Module, !IO)
         ;
             DebugTypes = no
         ),
@@ -212,21 +212,73 @@
         )
     ).
 
+    % Write out the inferred `pred' or `func' declarations for a list of
+    % predicates.  Don't write out the inferred types for assertions.
+    %
+:- pred write_type_inference_messages(list(pred_id)::in, module_info::in,
+    io::di, io::uo) is det.
+
+write_type_inference_messages([], _, !IO).
+write_type_inference_messages([PredId | PredIds], ModuleInfo, !IO) :-
+    module_info_pred_info(ModuleInfo, PredId, PredInfo),
+    pred_info_get_markers(PredInfo, Markers),
+    (
+        check_marker(Markers, marker_infer_type),
+        module_info_predids(ModuleInfo, ValidPredIds),
+        list.member(PredId, ValidPredIds),
+        \+ pred_info_get_goal_type(PredInfo, goal_type_promise(_))
+    ->
+        write_type_inference_message(PredInfo, !IO)
+    ;
+        true
+    ),
+    write_type_inference_messages(PredIds, ModuleInfo, !IO).
+
+    % Write out the inferred `pred' or `func' declaration
+    % for a single predicate.
+    %
+:- pred write_type_inference_message(pred_info::in, io::di, io::uo) is det.
+
+write_type_inference_message(PredInfo, !IO) :-
+    PredName = pred_info_name(PredInfo),
+    PredOrFunc = pred_info_is_pred_or_func(PredInfo),
+    Name = unqualified(PredName),
+    pred_info_context(PredInfo, Context),
+    pred_info_get_arg_types(PredInfo, VarSet, ExistQVars, Types0),
+    strip_builtin_qualifiers_from_type_list(Types0, Types),
+    pred_info_get_class_context(PredInfo, ClassContext),
+    pred_info_get_purity(PredInfo, Purity),
+    MaybeDet = no,
+    prog_out.write_context(Context, !IO),
+    io.write_string("Inferred ", !IO),
+    AppendVarNums = no,
+    (
+        PredOrFunc = predicate,
+        mercury_output_pred_type(VarSet, ExistQVars, Name, Types,
+            MaybeDet, Purity, ClassContext, Context, AppendVarNums, !IO)
+    ;
+        PredOrFunc = function,
+        pred_args_to_func_args(Types, ArgTypes, RetType),
+        mercury_output_func_type(VarSet, ExistQVars, Name, ArgTypes, RetType,
+            MaybeDet, Purity, ClassContext, Context, AppendVarNums, !IO)
+    ).
+
 :- pred typecheck_report_max_iterations_exceeded(io::di, io::uo) is det.
 
 typecheck_report_max_iterations_exceeded(!IO) :-
-    io.set_exit_status(1, !IO),
-    io.write_strings([
-        "Type inference iteration limit exceeded.\n",
-        "This probably indicates that your program has a type error.\n",
-        "You should declare the types explicitly.\n"
-    ], !IO),
     globals.io_lookup_int_option(type_inference_iteration_limit,
         MaxIterations, !IO),
-    io.format("(The current limit is %d iterations.  You can use the\n",
-        [i(MaxIterations)], !IO),
-    io.write_string("`--type-inference-iteration-limit' option " ++
-        "to increase the limit).\n", !IO).
+    Pieces = [words("Type inference iteration limit exceeded."),
+        words("This probably indicates that your program has a type error."),
+        words("You should declare the types explicitly."),
+        words("(The current limit is"), int_fixed(MaxIterations),
+        words("iterations."),
+        words("You can use the `--type-inference-iteration-limit' option"),
+        words("to increase the limit).")],
+    Msg = error_msg(no, no, 0, [always(Pieces)]),
+    Spec = error_spec(severity_error, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 %-----------------------------------------------------------------------------%
 
@@ -1124,7 +1176,7 @@
     % Typecheck the clause - first the head unification, and then the body.
     typecheck_var_has_type_list(HeadVars, ArgTypes, 1, !Info, !IO),
     typecheck_goal(Body0, Body, !Info, !IO),
-    checkpoint("end of clause", !Info, !IO),
+    type_checkpoint("end of clause", !.Info, !IO),
     !:Clause = !.Clause ^ clause_body := Body,
     typecheck_info_set_context(Context, !Info),
     typecheck_check_for_ambiguity(clause_only, HeadVars, !Info, !IO).
@@ -1237,32 +1289,32 @@
 typecheck_goal_2(GoalExpr0, GoalExpr, GoalInfo, !Info, !IO) :-
     (
         GoalExpr0 = conj(ConjType, List0),
-        checkpoint("conj", !Info, !IO),
+        type_checkpoint("conj", !.Info, !IO),
         typecheck_goal_list(List0, List, !Info, !IO),
         GoalExpr = conj(ConjType, List)
     ;
         GoalExpr0 = disj(List0),
-        checkpoint("disj", !Info, !IO),
+        type_checkpoint("disj", !.Info, !IO),
         typecheck_goal_list(List0, List, !Info, !IO),
         GoalExpr = disj(List)
     ;
         GoalExpr0 = if_then_else(Vars, Cond0, Then0, Else0),
-        checkpoint("if", !Info, !IO),
+        type_checkpoint("if", !.Info, !IO),
         typecheck_goal(Cond0, Cond, !Info, !IO),
-        checkpoint("then", !Info, !IO),
+        type_checkpoint("then", !.Info, !IO),
         typecheck_goal(Then0, Then, !Info, !IO),
-        checkpoint("else", !Info, !IO),
+        type_checkpoint("else", !.Info, !IO),
         typecheck_goal(Else0, Else, !Info, !IO),
         ensure_vars_have_a_type(Vars, !Info, !IO),
         GoalExpr = if_then_else(Vars, Cond, Then, Else)
     ;
         GoalExpr0 = negation(SubGoal0),
-        checkpoint("not", !Info, !IO),
+        type_checkpoint("not", !.Info, !IO),
         typecheck_goal(SubGoal0, SubGoal, !Info, !IO),
         GoalExpr = negation(SubGoal)
     ;
         GoalExpr0 = scope(Reason, SubGoal0),
-        checkpoint("scope", !Info, !IO),
+        type_checkpoint("scope", !.Info, !IO),
         typecheck_goal(SubGoal0, SubGoal, !Info, !IO),
         (
             Reason = exist_quant(Vars),
@@ -1284,7 +1336,7 @@
         GoalExpr = scope(Reason, SubGoal)
     ;
         GoalExpr0 = plain_call(_, ProcId, Args, BI, UC, Name),
-        checkpoint("call", !Info, !IO),
+        type_checkpoint("call", !.Info, !IO),
         list.length(Args, Arity),
         CurCall = simple_call_id(predicate, Name, Arity),
         typecheck_info_set_called_predid(plain_call_id(CurCall), !Info),
@@ -1298,7 +1350,7 @@
         (
             GenericCall0 = higher_order(PredVar, Purity, _, _),
             GenericCall = GenericCall0,
-            checkpoint("higher-order call", !Info, !IO),
+            type_checkpoint("higher-order call", !.Info, !IO),
             typecheck_higher_order_call(PredVar, Purity, Args, !Info, !IO)
         ;
             GenericCall0 = class_method(_, _, _, _),
@@ -1307,7 +1359,7 @@
         ;
             GenericCall0 = event_call(EventName),
             GenericCall = GenericCall0,
-            checkpoint("event call", !Info, !IO),
+            type_checkpoint("event call", !.Info, !IO),
             typecheck_event_call(EventName, Args, !Info, !IO)
         ;
             GenericCall0 = cast(_),
@@ -1318,7 +1370,7 @@
         GoalExpr = generic_call(GenericCall, Args, Modes, Detism)
     ;
         GoalExpr0 = unify(LHS, RHS0, UnifyMode, Unification, UnifyContext),
-        checkpoint("unify", !Info, !IO),
+        type_checkpoint("unify", !.Info, !IO),
         typecheck_info_set_arg_num(0, !Info),
         typecheck_info_set_unify_context(UnifyContext, !Info),
         goal_info_get_goal_path(GoalInfo, GoalPath),
@@ -1352,7 +1404,7 @@
 
 typecheck_goal_2_shorthand(bi_implication(LHS0, RHS0),
         bi_implication(LHS, RHS), !Info, !IO) :-
-    checkpoint("<=>", !Info, !IO),
+    type_checkpoint("<=>", !.Info, !IO),
     typecheck_goal(LHS0, LHS, !Info, !IO),
     typecheck_goal(RHS0, RHS, !Info, !IO).
 
@@ -1654,7 +1706,8 @@
     typecheck_info::in, typecheck_info::out, io::di, io::uo) is det.
 
 typecheck_var_has_arg_type_list([], _, ArgTypeAssignSet, !Info, !IO) :-
-    convert_nonempty_args_type_assign_set(ArgTypeAssignSet, TypeAssignSet),
+    TypeAssignSet =
+        convert_args_type_assign_set_check_empty_args(ArgTypeAssignSet),
     typecheck_info_set_type_assign_set(TypeAssignSet, !Info).
 
 typecheck_var_has_arg_type_list([Var | Vars], ArgNum, ArgTypeAssignSet0, !Info,
@@ -2566,7 +2619,7 @@
 
     typecheck_info_get_module_info(Info, ModuleInfo),
     module_info_get_predicate_table(ModuleInfo, PredTable),
-    unqualify_name(FuncName, UnqualFuncName),
+    UnqualFuncName = unqualify_name(FuncName),
     (
         Info ^ is_field_access_function = no,
         \+ predicate_table_search_func_m_n_a(PredTable, is_fully_qualified,
Index: compiler/typecheck_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck_errors.m,v
retrieving revision 1.28
diff -u -b -r1.28 typecheck_errors.m
--- compiler/typecheck_errors.m	5 Sep 2006 06:21:33 -0000	1.28
+++ compiler/typecheck_errors.m	7 Sep 2006 04:59:50 -0000
@@ -51,8 +51,7 @@
     io::di, io::uo) is det.
 
 :- pred report_error_unif_var_var(typecheck_info::in,
-    prog_var::in, prog_var::in, type_assign_set::in, io::di, io::uo)
-    is det.
+    prog_var::in, prog_var::in, type_assign_set::in, io::di, io::uo) is det.
 
 :- pred report_error_lambda_var(typecheck_info::in, pred_or_func::in,
     lambda_eval_method::in, prog_var::in, list(prog_var)::in,
@@ -85,20 +84,6 @@
     io::di, io::uo) is det.
 
 %-----------------------------------------------------------------------------%
-
-    % Write out the inferred `pred' or `func' declarations
-    % for a list of predicates.  Don't write out the inferred types
-    % for assertions.
-    %
-:- pred write_inference_messages(list(pred_id)::in, module_info::in,
-    io::di, io::uo) is det.
-
-    % Used for debugging typechecking.
-    %
-:- pred checkpoint(string::in, typecheck_info::in, typecheck_info::out,
-    io::di, io::uo) is det.
-
-%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
 :- implementation.
@@ -110,13 +95,11 @@
 :- import_module hlds.pred_table.
 :- import_module libs.compiler_util.
 :- import_module libs.globals.
-:- import_module libs.options.
 :- import_module parse_tree.error_util.
 :- import_module parse_tree.mercury_to_mercury.
 :- import_module parse_tree.modules.
 :- import_module parse_tree.prog_io_util.
 :- import_module parse_tree.prog_mode.
-:- import_module parse_tree.prog_out.
 :- import_module parse_tree.prog_type.
 :- import_module parse_tree.prog_type_subst.
 :- import_module parse_tree.prog_util.
@@ -147,8 +130,10 @@
         OtherIds = [_ | _]
     ->
         typecheck_find_arities(Preds, OtherIds, Arities),
-        report_error_pred_num_args(!.Info, PredCallId, Arities, !IO)
+        Spec = report_error_pred_num_args(!.Info, PredCallId, Arities)
     ;
+        UndefMsg = report_error_undef_pred(!.Info, PredCallId),
+        (
         ( PredOrFunc0 = predicate, PredOrFunc = function
         ; PredOrFunc0 = function, PredOrFunc = predicate
         ),
@@ -157,11 +142,16 @@
             PredOrFunc, SymName, OtherIds),
         OtherIds = [_ | _]
     ->
-        report_error_func_instead_of_pred(!.Info, PredOrFunc, PredCallId, !IO)
+            KindMsg = report_error_func_instead_of_pred(!.Info, PredOrFunc),
+            Msgs = [UndefMsg, KindMsg]
     ;
-        report_error_undef_pred(!.Info, PredCallId, !IO)
+            Msgs = [UndefMsg]
     ),
-    typecheck_info_set_found_error(yes, !Info).
+        Spec = error_spec(severity_error, phase_type_check, Msgs)
+    ),
+    typecheck_info_set_found_error(yes, !Info),
+    % XXX _NumErrors
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 :- pred typecheck_find_arities(pred_table::in, list(pred_id)::in,
     list(int)::out) is det.
@@ -172,166 +162,135 @@
     Arity = pred_info_orig_arity(PredInfo),
     typecheck_find_arities(Preds, PredIds, Arities).
 
-:- pred report_error_pred_num_args(typecheck_info::in, simple_call_id::in,
-    list(int)::in, io::di, io::uo) is det.
+:- func report_error_pred_num_args(typecheck_info, simple_call_id,
+    list(int)) = error_spec.
 
-report_error_pred_num_args(Info, SimpleCallId, Arities, !IO) :-
+report_error_pred_num_args(Info, SimpleCallId, Arities) = Spec :-
     SimpleCallId = simple_call_id(PredOrFunc, SymName, Arity),
-    write_context_and_pred_id(Info, !IO),
+    Pieces = in_clause_for_pieces(Info) ++
+        [words("error:")] ++
+        error_num_args_to_pieces(yes(PredOrFunc), Arity, Arities) ++ [nl] ++
+        [words("in call to"), p_or_f(PredOrFunc), sym_name(SymName),
+        suffix("."), nl],
     typecheck_info_get_context(Info, Context),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  error: ", !IO),
-    report_error_num_args(yes(PredOrFunc), Arity, Arities, !IO),
-    io.nl(!IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  in call to ", !IO),
-    prog_out.write_pred_or_func(PredOrFunc, !IO),
-    io.write_string(" `", !IO),
-    prog_out.write_sym_name(SymName, !IO),
-    io.write_string("'.\n", !IO).
+    Spec = error_spec(severity_error, phase_type_check,
+        [simple_msg(Context, [always(Pieces)])]).
 
-:- pred report_error_func_instead_of_pred(typecheck_info::in, pred_or_func::in,
-    simple_call_id::in, io::di, io::uo) is det.
+:- func report_error_func_instead_of_pred(typecheck_info, pred_or_func)
+    = error_msg.
 
-report_error_func_instead_of_pred(Info, PredOrFunc, PredCallId, !IO) :-
-    report_error_undef_pred(Info, PredCallId, !IO),
-    typecheck_info_get_context(Info, Context),
-    PredOrFuncStr = pred_or_func_to_full_str(PredOrFunc),
+report_error_func_instead_of_pred(Info, PredOrFunc) = Msg :-
     (
         PredOrFunc = function,
-        Pieces = [words("(There is a *" ++ PredOrFuncStr ++ "*"),
+        Pieces = [words("(There is a"),
+            prefix("*"), p_or_f(PredOrFunc), suffix("*"),
             words("with that name, however."), nl,
-            words("Perhaps you forgot to add"),
-            fixed("` = ...'?)")]
+            words("Perhaps you forgot to add"), fixed("` = ...'?)"), nl]
     ;
         PredOrFunc = predicate,
-        Pieces = [words("(There is a *" ++ PredOrFuncStr ++ "*"),
-            words("with that name, however.)")]
+        Pieces = [words("(There is a"),
+            prefix("*"), p_or_f(PredOrFunc), suffix("*"),
+            words("with that name, however.)"), nl]
     ),
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    typecheck_info_get_context(Info, Context),
+    Msg = simple_msg(Context, [always(Pieces)]).
 
-:- pred report_error_undef_pred(typecheck_info::in, simple_call_id::in,
-    io::di, io::uo) is det.
+:- func report_error_undef_pred(typecheck_info, simple_call_id) = error_msg.
 
-report_error_undef_pred(Info, SimpleCallId, !IO) :-
+report_error_undef_pred(Info, SimpleCallId) = Msg :-
     SimpleCallId = simple_call_id(_PredOrFunc, PredName, Arity),
     typecheck_info_get_context(Info, Context),
-    write_typecheck_info_context(Info, !IO),
+    InClauseForPieces = in_clause_for_pieces(Info),
+    InClauseForComponent = always(InClauseForPieces),
     (
         PredName = unqualified("->"),
         ( Arity = 2 ; Arity = 4 )
     ->
-        io.write_string("  error: `->' without `;'.\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string("  Note: the else part is not optional.\n", !IO),
-            prog_out.write_context(Context, !IO),
-            io.write_string("  Every if-then must have an else.\n", !IO)
-        ;
-            VerboseErrors = no,
-            globals.io_set_extra_error_info(yes, !IO)
-        )
+        MainPieces = [words("error: `->' without `;'."), nl],
+        MainComponent = always(MainPieces),
+        VerbosePieces =
+            [words("Note: the else part is not optional."), nl,
+            words("Every if-then must have an else."), nl],
+        VerboseComponent = verbose_only(VerbosePieces),
+        Components = [MainComponent, VerboseComponent]
     ;
         PredName = unqualified("else"),
         ( Arity = 2 ; Arity = 4 )
     ->
-        io.write_string("  error: unmatched `else'.\n", !IO)
+        Components = [always([words("error: unmatched `else'."), nl])]
     ;
         PredName = unqualified("if"),
         ( Arity = 2 ; Arity = 4 )
     ->
-        io.write_string("  error: `if' without `then' or `else'.\n", !IO)
+        Pieces = [words("error: `if' without `then' or `else'."), nl],
+        Components = [always(Pieces)]
     ;
         PredName = unqualified("then"),
         ( Arity = 2 ; Arity = 4 )
     ->
-        io.write_string("  error: `then' without `if' or `else'.\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string("  Note: the `else' part is not optional.\n", !IO),
-            prog_out.write_context(Context, !IO),
-            io.write_string("  Every if-then must have an `else'.\n", !IO)
-        ;
-            VerboseErrors = no,
-            globals.io_set_extra_error_info(yes, !IO)
-        )
+        MainPieces = [words("error: `then' without `if' or `else'."), nl],
+        MainComponent = always(MainPieces),
+        VerbosePieces =
+            [words("Note: the `else' part is not optional."), nl,
+            words("Every if-then must have an `else'."), nl],
+        VerboseComponent = verbose_only(VerbosePieces),
+        Components = [MainComponent, VerboseComponent]
     ;
         PredName = unqualified("apply"),
         Arity >= 1
     ->
-        report_error_apply_instead_of_pred(Info, !IO)
+        Components = report_apply_instead_of_pred
     ;
         PredName = unqualified(PurityString),
         Arity = 1,
         ( PurityString = "impure" ; PurityString = "semipure" )
     ->
-        io.write_string("  error: `", !IO),
-        io.write_string(PurityString, !IO),
-        io.write_string("' marker in an inappropriate place.\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string("  Such markers only belong " ++
-                "before predicate calls.\n", !IO)
-        ;
-            VerboseErrors = no,
-            globals.io_set_extra_error_info(yes, !IO)
-        )
+        MainPieces = [words("error:"), quote(PurityString),
+            words("marker in an inappropriate place."), nl],
+        MainComponent = always(MainPieces),
+        VerbosePieces =
+            [words("Such markers only belong before predicate calls."), nl],
+        VerboseComponent = verbose_only(VerbosePieces),
+        Components = [MainComponent, VerboseComponent]
     ;
         PredName = unqualified("some"),
         Arity = 2
     ->
-        io.write_string("  syntax error in existential " ++
-            "quantification: first\n", !IO),
-        prog_out.write_context(Context, !IO),
-        io.write_string("  argument of `some' should be " ++
-            "a list of variables.\n", !IO)
+        Pieces = [words("syntax error in existential quantification:"),
+            words("first argument of `some' should be a list of variables."),
+            nl],
+        Components = [always(Pieces)]
     ;
-        io.write_string("  error: undefined ", !IO),
-        write_simple_call_id(SimpleCallId, !IO),
+        MainPieces = [words("error: undefined"), simple_call(SimpleCallId)],
         ( PredName = qualified(ModuleQualifier, _) ->
-            maybe_report_missing_import(Info, ModuleQualifier, !IO)
+            Pieces = MainPieces ++
+                maybe_report_missing_import_addendum(Info, ModuleQualifier)
         ;
-            io.write_string(".\n", !IO)
-        )
-    ).
+            Pieces = MainPieces ++ [suffix("."), nl]
+        ),
+        Components = [always(Pieces)]
+    ),
+    Msg = simple_msg(Context, [InClauseForComponent | Components]).
 
-:- pred report_error_apply_instead_of_pred(typecheck_info::in, io::di, io::uo)
-    is det.
+:- func report_apply_instead_of_pred = list(error_msg_component).
 
-report_error_apply_instead_of_pred(Info, !IO) :-
-    typecheck_info_get_context(Info, Context),
-    Pieces1 = [words("error: the language construct `apply'"),
+report_apply_instead_of_pred = Components :-
+    MainPieces = [words("error: the language construct `apply'"),
         words("should be used as an expression, not as a goal."), nl],
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
-        Pieces2 = [words("Perhaps you forgot to add"),
-            fixed("` = ...'?)"), nl,
-            words("If you're trying to invoke"),
-            words("a higher-order predicate,"),
+    MainComponent = always(MainPieces),
+    VerbosePieces =
+        [words("Perhaps you forgot to add"), fixed("` = ...'?)"), nl,
+        words("If you're trying to invoke a higher-order predicate,"),
             words("use `call', not `apply'."), nl,
-            words("If you're trying to curry"),
-            words("a higher-order function,"),
+        words("If you're trying to curry a higher-order function,"),
             words("use a forwarding function:"), nl,
-            words("e.g. instead of "),
-            fixed("`NewFunc = apply(OldFunc, X)'"),
-            words("use"),
-            fixed("`NewFunc = my_apply(OldFunc, X)'"),
+        words("e.g. instead of "), fixed("`NewFunc = apply(OldFunc, X)'"),
+        words("use"), fixed("`NewFunc = my_apply(OldFunc, X)'"),
             words("where `my_apply' is defined"),
             words("with the appropriate arity, e.g."),
-            fixed("`my_apply(Func, X, Y) :- apply(Func, X, Y).'")]
-    ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO),
-        Pieces2 = []
-    ),
-    write_error_pieces_not_first_line(Context, 0, Pieces1 ++ Pieces2, !IO).
+        fixed("`my_apply(Func, X, Y) :- apply(Func, X, Y).'")],
+    VerboseComponent = verbose_only(VerbosePieces),
+    Components = [MainComponent, VerboseComponent].
 
 %-----------------------------------------------------------------------------%
 
@@ -339,51 +298,63 @@
     typecheck_info_get_context(!.Info, Context),
     Pieces = [words("There is no event named"), quote(EventName),
         suffix(".")],
-    error_util.write_error_pieces(Context, 0, Pieces, !IO).
+    Msg = simple_msg(Context, [always(Pieces)]),
+    Spec = error_spec(severity_warning, phase_type_check, [Msg]),
+    typecheck_info_set_found_error(yes, !Info),
+    % XXX _NumErrors
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 %-----------------------------------------------------------------------------%
 
 report_no_clauses(MessageKind, PredId, PredInfo, ModuleInfo, !IO) :-
-    io.get_exit_status(Status, !IO),
-    ( Status = 0 ->
-        pred_info_context(PredInfo, Context),
         PredPieces = describe_one_pred_name(ModuleInfo,
             should_not_module_qualify, PredId),
-        Pieces = [words(MessageKind ++ ": no clauses for ") | PredPieces] ++
-            [suffix(".")],
-        error_util.write_error_pieces(Context, 0, Pieces, !IO)
-    ;
+    Pieces = [words(MessageKind), suffix(":"),
+        words("no clauses for ") | PredPieces] ++ [suffix(".")],
+    pred_info_context(PredInfo, Context),
         % It is possible (and even likely) that the error that got the exit
         % status set was caused by a syntax error in a clause defining this
-        % predicate or function. Reporting a missing clause would therefore
-        % be quite likely to be redundant and misleading. Even if this
-        % predicate or function truly has no clauses, this error would be
-        % caught once the other errors (the ones leading to the exit status)
-        % are fixed by the programmer.
-        true
-    ).
+    % predicate or function. Reporting a missing clause could therefore
+    % be redundant and misleading. Even if this predicate or function truly
+    % has no clauses, this error would be caught once the other errors
+    % (the ones leading to the exit status) are fixed by the programmer.
+    %
+    % However, right now we have no means to distinguish the case where the
+    % exit status being set to nonzero was caused by an actual syntax error,
+    % and the case where it was set by a no clauses error for another
+    % predicate. Since we don't want to limit the number of predicates
+    % without clauses we warn about in a single compiler invocation to one,
+    % we choose (as the lesser of two evils) to always report the error.
+    Msg = simple_msg(Context, [always(Pieces)]),
+    Spec = error_spec(severity_warning, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 %-----------------------------------------------------------------------------%
 
 report_warning_too_much_overloading(Info, !IO) :-
+    Msgs = warning_too_much_overloading_to_msgs(Info),
+    Spec = error_spec(severity_warning, phase_type_check, Msgs),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
+
+:- func warning_too_much_overloading_to_msgs(typecheck_info) = list(error_msg).
+
+warning_too_much_overloading_to_msgs(Info) = Msgs :-
     typecheck_info_get_context(Info, Context),
-    make_pred_id_preamble(Info, Preamble),
-    InitWarning = [fixed(Preamble),
-        words("warning: highly ambiguous overloading."), nl],
-
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
-        VerboseWarning = [
-            words("This may cause type-checking to be very slow."),
+    InitWarningPieces = in_clause_for_pieces(Info) ++
+        [words("warning: highly ambiguous overloading."), nl],
+    InitWarningComponent = always(InitWarningPieces),
+
+    VerboseWarningPieces =
+        [words("This may cause type-checking to be very slow."),
             words("It may also make your code difficult to understand."), nl],
-        InitVerboseWarning = InitWarning ++ VerboseWarning
-    ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO),
-        InitVerboseWarning = InitWarning
-    ),
-    FirstSpec = error_msg_spec(yes, Context, 0, InitVerboseWarning),
+    VerboseWarningComponent = verbose_only(VerboseWarningPieces),
+
+    FirstMsg = simple_msg(Context,
+        [InitWarningComponent, VerboseWarningComponent]),
 
     typecheck_info_get_overloaded_symbols(Info, OverloadedSymbolSet),
     map.to_assoc_list(OverloadedSymbolSet, OverloadedSymbols),
@@ -391,45 +362,43 @@
         assoc_list.map_values_only(sort_and_remove_dups, OverloadedSymbols),
     (
         OverloadedSymbolsSortedContexts = [],
-        Specs = [FirstSpec]
+        Msgs = [FirstMsg]
     ;
         (
             OverloadedSymbolsSortedContexts = [_ - Contexts],
             (
                 Contexts = [],
                 unexpected(this_file,
-                    "report_warning_too_much_overloading: no contexts")
+                    "warning_too_much_overloading_to_msgs: no contexts")
             ;
                 Contexts = [_],
-                SecondSpecPieces =
+                SecondPieces =
                     [words("The following symbol was overloaded"),
                     words("in the following context."), nl]
             ;
                 Contexts = [_, _ | _],
-                SecondSpecPieces =
+                SecondPieces =
                     [words("The following symbol was overloaded"),
                     words("in the following contexts."), nl]
             )
         ;
             OverloadedSymbolsSortedContexts = [_, _ | _],
-            SecondSpecPieces =
+            SecondPieces =
                 [words("The following symbols were overloaded"),
                 words("in the following contexts."), nl]
         ),
-        SecondSpec = error_msg_spec(no, Context, 0, SecondSpecPieces),
+        SecondMsg = simple_msg(Context, [always(SecondPieces)]),
         typecheck_info_get_module_info(Info, ModuleInfo),
-        DetailSpecsList = list.map(describe_overloaded_symbol(ModuleInfo),
+        DetailMsgsList = list.map(describe_overloaded_symbol(ModuleInfo),
             OverloadedSymbolsSortedContexts),
-        list.condense(DetailSpecsList, DetailSpecs),
-        Specs = [FirstSpec, SecondSpec | DetailSpecs]
-    ),
-    record_warning(!IO),
-    write_error_specs(Specs, !IO).
+        list.condense(DetailMsgsList, DetailMsgs),
+        Msgs = [FirstMsg, SecondMsg | DetailMsgs]
+    ).
 
 :- func describe_overloaded_symbol(module_info,
-    pair(overloaded_symbol, list(prog_context))) = list(error_msg_spec).
+    pair(overloaded_symbol, list(prog_context))) = list(error_msg).
 
-describe_overloaded_symbol(ModuleInfo, Symbol - SortedContexts) = Specs :-
+describe_overloaded_symbol(ModuleInfo, Symbol - SortedContexts) = Msgs :-
     (
         SortedContexts = [],
         unexpected(this_file, "describe_overloaded_symbol: no context")
@@ -440,7 +409,7 @@
         (
             Symbol = overloaded_pred(CallId, PredIds),
             StartPieces = [words("The predicate symbol"),
-                simple_call_id(CallId), suffix("."), nl,
+                simple_call(CallId), suffix("."), nl,
                 words("The possible matches are:"), nl_indent_delta(1)],
             PredIdPiecesList = list.map(describe_one_pred_name(ModuleInfo,
                 should_module_qualify), PredIds),
@@ -448,7 +417,7 @@
                 [suffix(".")]),
             FirstPieces = StartPieces ++ PredIdPieces,
             LaterPieces = [words("The predicate symbol"),
-                simple_call_id(CallId), words("is also overloaded here.")]
+                simple_call(CallId), words("is also overloaded here.")]
         ;
             Symbol = overloaded_func(ConsId, Sources),
             ( ConsId = cons(SymName, Arity) ->
@@ -467,17 +436,14 @@
             LaterPieces = [words("The function symbol"), ConsIdPiece,
                 words("is also overloaded here.")]
         ),
-        FirstSpec = error_msg_spec(no, FirstContext, 0, FirstPieces),
-        LaterSpecs = list.map(context_to_error_msg_spec(LaterPieces),
-            LaterContexts),
-        Specs = [FirstSpec | LaterSpecs]
+        FirstMsg = simple_msg(FirstContext, [always(FirstPieces)]),
+        LaterMsgs = list.map(context_to_error_msg(LaterPieces), LaterContexts),
+        Msgs = [FirstMsg | LaterMsgs]
     ).
 
-:- func context_to_error_msg_spec(list(format_component), prog_context)
-    = error_msg_spec.
+:- func context_to_error_msg(list(format_component), prog_context) = error_msg.
 
-context_to_error_msg_spec(Pieces, Context) =
-    error_msg_spec(no, Context, 0, Pieces).
+context_to_error_msg(Pieces, Context) = simple_msg(Context, [always(Pieces)]).
 
 :- func describe_cons_type_info_source(module_info, cons_type_info_source)
     = list(format_component).
@@ -519,33 +485,25 @@
     typecheck_info_get_varset(Info, VarSet),
     typecheck_info_get_unify_context(Info, UnifyContext),
 
-    write_context_and_pred_id(Info, !IO),
-    hlds_out.write_unify_context(UnifyContext, Context, !IO),
-
-    prog_out.write_context(Context, !IO),
-    io.write_string("  type error in unification of variable `", !IO),
-    mercury_output_var(X, VarSet, no, !IO),
-    io.write_string("'\n", !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  and variable `", !IO),
-    mercury_output_var(Y, VarSet, no, !IO),
-    io.write_string("'.\n", !IO),
-
-    prog_out.write_context(Context, !IO),
-    io.write_string("  `", !IO),
-    mercury_output_var(X, VarSet, no, !IO),
-    io.write_string("'", !IO),
-    write_type_of_var(Info, Context, TypeAssignSet, X, !IO),
-    io.write_string(",\n", !IO),
-
-    prog_out.write_context(Context, !IO),
-    io.write_string("  `", !IO),
-    mercury_output_var(Y, VarSet, no, !IO),
-    io.write_string("'", !IO),
-    write_type_of_var(Info, Context, TypeAssignSet, Y, !IO),
-    io.write_string(".\n", !IO),
+    InClauseForPieces = in_clause_for_pieces(Info),
+    unify_context_to_pieces(UnifyContext, [], UnifyContextPieces),
 
-    write_type_assign_set_msg(TypeAssignSet, VarSet, !IO).
+    MainPieces = [words("type error in unification of variable"),
+        quote(mercury_var_to_string(X, VarSet, no)), nl,
+        words("and variable"),
+        quote(mercury_var_to_string(Y, VarSet, no)), suffix("."), nl,
+        quote(mercury_var_to_string(X, VarSet, no))] ++
+        type_of_var_to_pieces(TypeAssignSet, X) ++ [suffix(","), nl,
+        quote(mercury_var_to_string(Y, VarSet, no))] ++
+        type_of_var_to_pieces(TypeAssignSet, Y) ++ [suffix("."), nl],
+    VerbosePieces = type_assign_set_msg_to_pieces(TypeAssignSet, VarSet),
+    Msg = simple_msg(Context,
+        [always(InClauseForPieces), always(UnifyContextPieces),
+        always(MainPieces), verbose_only(VerbosePieces)]),
+    Spec = error_spec(severity_error, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 report_error_lambda_var(Info, PredOrFunc, _EvalMethod, Var, ArgVars,
         TypeAssignSet, !IO) :-
@@ -553,71 +511,69 @@
     typecheck_info_get_varset(Info, VarSet),
     typecheck_info_get_unify_context(Info, UnifyContext),
 
-    write_context_and_pred_id(Info, !IO),
-    hlds_out.write_unify_context(UnifyContext, Context, !IO),
-
-    prog_out.write_context(Context, !IO),
-    io.write_string("  type error in unification of ", !IO),
-    write_argument_name(VarSet, Var, !IO),
-    io.write_string("\n", !IO),
-    prog_out.write_context(Context, !IO),
+    InClauseForPieces = in_clause_for_pieces(Info),
+    unify_context_to_pieces(UnifyContext, [], UnifyContextPieces),
 
+    Pieces1 = [words("type error in unification of")] ++
+        argument_name_to_pieces(VarSet, Var) ++ [nl],
     (
         PredOrFunc = predicate,
-        io.write_string("  and `", !IO),
-        io.write_string("pred(", !IO),
-        mercury_output_vars(ArgVars, VarSet, no, !IO),
-        io.write_string(") :- ...':\n", !IO)
+        Pieces2 = [words("and"), prefix("pred("),
+            words(mercury_vars_to_string(ArgVars, VarSet, no)),
+            suffix(")"), words(":- ...':"), nl]
     ;
         PredOrFunc = function,
         pred_args_to_func_args(ArgVars, FuncArgs, RetVar),
-        io.write_string("  and `", !IO),
-        io.write_string("func(", !IO),
-        mercury_output_vars(FuncArgs, VarSet, no, !IO),
-        io.write_string(") = ", !IO),
-        mercury_output_var(RetVar, VarSet, no, !IO),
-        io.write_string(" :- ...':\n", !IO)
-    ),
-
-    prog_out.write_context(Context, !IO),
-    io.write_string("  ", !IO),
-    write_argument_name(VarSet, Var, !IO),
-    write_type_of_var(Info, Context, TypeAssignSet, Var, !IO),
-    io.write_string(",\n", !IO),
+        Pieces2 = [words("and"), prefix("func("),
+            words(mercury_vars_to_string(FuncArgs, VarSet, no)),
+            suffix(")"), fixed("="),
+            words(mercury_var_to_string(RetVar, VarSet, no)),
+            words(":- ...':"), nl]
+    ),
 
-    prog_out.write_context(Context, !IO),
-    io.write_string("  lambda expression has type `", !IO),
+    Pieces3 = argument_name_to_pieces(VarSet, Var) ++
+        type_of_var_to_pieces(TypeAssignSet, Var) ++ [suffix(","), nl],
+
+    LambdaExprStr = "lambda expression has type",
+    Pieces4a = [words(LambdaExprStr), prefix("`")],
     (
         PredOrFunc = predicate,
-        io.write_string("pred", !IO),
-        ( ArgVars = [] ->
-            true
+        (
+            ArgVars = [],
+            Pieces4b = [words("pred")]
         ;
-            io.write_string("(_", !IO),
+            ArgVars = [_ | _],
             list.length(ArgVars, NumArgVars),
-            NumArgVars1 = NumArgVars - 1,
-            list.duplicate(NumArgVars1, ", _", Strings),
-            io.write_strings(Strings, !IO),
-            io.write_string(")", !IO)
+            list.duplicate(NumArgVars - 1, ", _", Strings),
+            JoinedString = string.join_list("", Strings),
+            Pieces4b = [words("pred(_" ++ JoinedString ++ ")")]
         )
     ;
         PredOrFunc = function,
-        io.write_string("func", !IO),
-        pred_args_to_func_args(ArgVars, FuncArgs2, _),
-        ( FuncArgs2 = [] ->
-            true
-        ;
-            io.write_string("(_", !IO),
-            list.length(FuncArgs2, NumArgVars),
-            NumArgVars1 = NumArgVars - 1,
-            list.duplicate(NumArgVars1, ", _", Strings),
-            io.write_strings(Strings, !IO),
-            io.write_string(")", !IO)
-        ),
-        io.write_string(" = _", !IO)
+        pred_args_to_func_args(ArgVars, FuncArgVars, _),
+        (
+            FuncArgVars = [],
+            Pieces4b = [words("func = _")]
+        ;
+            FuncArgVars = [_ | _],
+            list.length(FuncArgVars, NumArgVars),
+            list.duplicate(NumArgVars - 1, ", _", Strings),
+            JoinedString = string.join_list("", Strings),
+            Pieces4b = [words("func(_" ++ JoinedString ++ ") = _")]
+        )
     ),
-    io.write_string("'.\n", !IO),
-    write_type_assign_set_msg(TypeAssignSet, VarSet, !IO).
+    Pieces4c = [suffix("'."), nl],
+    Pieces4 = Pieces4a ++ Pieces4b ++ Pieces4c,
+
+    VerbosePieces = type_assign_set_msg_to_pieces(TypeAssignSet, VarSet),
+    Msg = simple_msg(Context,
+        [always(InClauseForPieces ++ UnifyContextPieces),
+        always(Pieces1 ++ Pieces2 ++ Pieces3 ++ Pieces4),
+        verbose_only(VerbosePieces)]),
+    Spec = error_spec(severity_error, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 report_error_functor_type(Info, Var, ConsDefnList, Functor, Arity,
         TypeAssignSet, !IO) :-
@@ -625,31 +581,31 @@
     typecheck_info_get_varset(Info, VarSet),
     typecheck_info_get_unify_context(Info, UnifyContext),
 
-    write_context_and_pred_id(Info, !IO),
-    hlds_out.write_unify_context(UnifyContext, Context, !IO),
-
-    prog_out.write_context(Context, !IO),
-    io.write_string("  type error in unification of ", !IO),
-    write_argument_name(VarSet, Var, !IO),
-    io.write_string("\n", !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  and ", !IO),
-    write_functor_name(Functor, Arity, !IO),
-    io.write_string(".\n", !IO),
-
-    prog_out.write_context(Context, !IO),
-    io.write_string("  ", !IO),
-    write_argument_name(VarSet, Var, !IO),
-    write_type_of_var(Info, Context, TypeAssignSet, Var, !IO),
-    io.write_string(",\n", !IO),
-
-    prog_out.write_context(Context, !IO),
-    io.write_string("  ", !IO),
-    write_functor_name(Functor, Arity, !IO),
-    write_type_of_functor(Functor, Arity, Context, ConsDefnList, !IO),
-    io.write_string(".\n", !IO),
-
-    write_type_assign_set_msg(TypeAssignSet, VarSet, !IO).
+    InClauseForPieces = in_clause_for_pieces(Info),
+    % XXX We could append UnifyContextPieces after InClauseForPieces
+    % instead of after the empty list.
+    unify_context_to_pieces(UnifyContext, [], UnifyContextPieces),
+
+    MainPieces = [words("type error in unification of")] ++
+        argument_name_to_pieces(VarSet, Var) ++ [nl, words("and")] ++
+        functor_name_to_pieces(Functor, Arity) ++ [suffix("."), nl] ++
+
+        argument_name_to_pieces(VarSet, Var) ++
+        type_of_var_to_pieces(TypeAssignSet, Var) ++ [suffix(","), nl] ++
+
+        functor_name_to_pieces(Functor, Arity) ++
+        type_of_functor_to_pieces(Functor, Arity, ConsDefnList) ++
+        [suffix("."), nl],
+
+    VerbosePieces = type_assign_set_msg_to_pieces(TypeAssignSet, VarSet),
+
+    Msg = simple_msg(Context,
+        [always(InClauseForPieces ++ UnifyContextPieces),
+        always(MainPieces), verbose_only(VerbosePieces)]),
+    Spec = error_spec(severity_error, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 report_error_functor_arg_types(Info, Var, ConsDefnList, Functor, Args,
         ArgsTypeAssignSet, !IO) :-
@@ -659,23 +615,18 @@
     typecheck_info_get_module_info(Info, ModuleInfo),
     list.length(Args, Arity),
 
-    write_context_and_pred_id(Info, !IO),
-    hlds_out.write_unify_context(UnifyContext, Context, !IO),
+    InClauseForPieces = in_clause_for_pieces(Info),
+    unify_context_to_pieces(UnifyContext, [], UnifyContextPieces),
 
-    prog_out.write_context(Context, !IO),
-    io.write_string("  in unification of ", !IO),
-    write_argument_name(VarSet, Var, !IO),
-    io.write_string("\n", !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  and term `", !IO),
     strip_builtin_qualifier_from_cons_id(Functor, StrippedFunctor),
-    hlds_out.write_functor_cons_id(StrippedFunctor, Args, VarSet,
-        ModuleInfo, no, !IO),
-    io.write_string("':\n", !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  type error in argument(s) of ", !IO),
-    write_functor_name(StrippedFunctor, Arity, !IO),
-    io.write_string(".\n", !IO),
+    StrippedFunctorStr = functor_cons_id_to_string(StrippedFunctor, Args,
+        VarSet, ModuleInfo, no),
+
+    Pieces1 = [words("in unification of")] ++
+        argument_name_to_pieces(VarSet, Var) ++ [nl, words("and term"),
+        quote(StrippedFunctorStr), suffix(":"), nl,
+        words("type error in argument(s) of")] ++
+        functor_name_to_pieces(StrippedFunctor, Arity) ++ [suffix("."), nl],
 
     ConsArgTypesSet = list.map(get_callee_arg_types, ArgsTypeAssignSet),
 
@@ -694,41 +645,46 @@
             "report_error_functor_arg_types: no mismatches"),
         ComplexMismatches = []
     ->
-        report_mismatched_args(SimpleMismatches, yes, VarSet, Functor,
-            Context, !IO)
+        Pieces2 =
+            mismatched_args_to_pieces(SimpleMismatches, yes, VarSet, Functor),
+        VerboseComponents = []
     ;
-        % XXX If we can compute AllMismatches, then we should use it
-        % to report which arguments are OK, and which are suspect.
+        % XXX If we can compute AllMismatches, then we should use it to report
+        % which arguments are OK, and which are suspect.
 
-        convert_args_type_assign_set(ArgsTypeAssignSet, TypeAssignSet),
+        TypeAssignSet = convert_args_type_assign_set(ArgsTypeAssignSet),
 
-        %
-        % For polymorphic data structures,
-        % the type of `Var' (the functor's result type)
-        % can affect the valid types for the arguments.
-        %
+        % For polymorphic data structures, the type of `Var' (the functor's
+        % result type) can affect the valid types for the arguments.
         (
             % Could the type of the functor be polymorphic?
             list.member(ConsDefn, ConsDefnList),
             ConsDefn ^ cti_arg_types = [_ | _]
         ->
             % If so, print out the type of `Var'.
-            prog_out.write_context(Context, !IO),
-            io.write_string("  ", !IO),
-            write_argument_name(VarSet, Var, !IO),
-            write_type_of_var(Info, Context, TypeAssignSet, Var, !IO),
-            io.write_string(",\n", !IO)
-        ;
-            true
+            Pieces2a = argument_name_to_pieces(VarSet, Var) ++
+                type_of_var_to_pieces(TypeAssignSet, Var) ++
+                [suffix(","), nl]
+        ;
+            Pieces2a = []
         ),
 
-        prog_out.write_context(Context, !IO),
-        io.write_string("  ", !IO),
-        write_functor_name(Functor, Arity, !IO),
-        write_type_of_functor(Functor, Arity, Context, ConsDefnList, !IO),
-        write_types_of_vars(Args, VarSet, Context, Info, TypeAssignSet, !IO),
-        write_type_assign_set_msg(TypeAssignSet, VarSet, !IO)
-    ).
+        Pieces2b = functor_name_to_pieces(Functor, Arity) ++
+            type_of_functor_to_pieces(Functor, Arity, ConsDefnList) ++
+            types_of_vars_to_pieces(Args, VarSet, Info, TypeAssignSet),
+        Pieces2 = Pieces2a ++ Pieces2b,
+
+        VerbosePieces = type_assign_set_msg_to_pieces(TypeAssignSet, VarSet),
+        VerboseComponents = [verbose_only(VerbosePieces)]
+    ),
+
+    Msg = simple_msg(Context,
+        [always(InClauseForPieces ++ UnifyContextPieces),
+        always(Pieces1 ++ Pieces2) | VerboseComponents]),
+    Spec = error_spec(severity_error, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 :- type mismatch_info
     --->    mismatch_info(
@@ -805,12 +761,12 @@
             TVarSet, HeadTypeParams)
     ).
 
-:- pred report_mismatched_args(list(mismatch_info)::in, bool::in,
-    prog_varset::in, cons_id::in, prog_context::in, io::di, io::uo) is det.
+:- func mismatched_args_to_pieces(list(mismatch_info), bool, prog_varset,
+    cons_id) = list(format_component).
 
-report_mismatched_args([], _, _, _, _, !IO).
-report_mismatched_args([Mismatch | Mismatches], First, VarSet, Functor,
-        Context, !IO) :-
+mismatched_args_to_pieces([], _, _, _) = [].
+mismatched_args_to_pieces([Mismatch | Mismatches], First, VarSet, Functor)
+        = Pieces :-
     Mismatch = mismatch_info(ArgNum, Var, TypeMismatches),
     ( TypeMismatches = [TypeMismatch] ->
         TypeMismatch = type_mismatch(ActType, ExpType, TVarSet, HeadTypeParams)
@@ -818,7 +774,6 @@
         unexpected(this_file,
             "report_mismatched_args: more than one type mismatch")
     ),
-    prog_out.write_context(Context, !IO),
     (
         % Handle higher-order syntax such as ''(F, A) specially:
         % output
@@ -832,44 +787,42 @@
     ->
         (
             First = yes,
-            io.write_string("  Functor", !IO)
+            Pieces1 = [fixed("Functor")]
         ;
             First = no,
-            io.write_string("  argument ", !IO),
-            io.write_int(ArgNum - 1, !IO)
+            Pieces1 = [fixed("argument"), int_fixed(ArgNum - 1)]
         )
     ;
         (
             First = yes,
-            io.write_string("  Argument ", !IO)
+            Pieces1 = [fixed("Argument"), int_fixed(ArgNum)]
         ;
             First = no,
-            io.write_string("  argument ", !IO)
-        ),
-        io.write_int(ArgNum, !IO)
+            Pieces1 = [fixed("argument"), int_fixed(ArgNum)]
+        )
     ),
     ( varset.search_name(VarSet, Var, _) ->
-        io.write_string(" (", !IO),
-        mercury_output_var(Var, VarSet, no, !IO),
-        io.write_string(")", !IO)
-    ;
-        true
-    ),
-    io.write_string(" has type `", !IO),
-    output_type(ActType, TVarSet, HeadTypeParams, !IO),
-    io.write_string("',\n", !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  expected type was `", !IO),
-    output_type(ExpType, TVarSet, HeadTypeParams, !IO),
+        Pieces2 = [prefix("("),
+            words(mercury_var_to_string(Var, VarSet, no)),
+            suffix(")")]
+    ;
+        Pieces2 = []
+    ),
+    Pieces3 = [words("has type"), prefix("`")] ++
+        type_to_pieces(ActType, TVarSet, HeadTypeParams) ++
+        [suffix("'"), suffix(","), nl] ++
+        [words("expected type was"), prefix("`")] ++
+        type_to_pieces(ExpType, TVarSet, HeadTypeParams) ++
+        [suffix("'")],
     (
         Mismatches = [],
-        io.write_string("'.\n", !IO)
+        Pieces4 = [suffix("."), nl]
     ;
         Mismatches = [_ | _],
-        io.write_string("';\n", !IO),
-        report_mismatched_args(Mismatches, no, VarSet, Functor,
-            Context, !IO)
-    ).
+        Pieces4 = [suffix(";"), nl] ++
+            mismatched_args_to_pieces(Mismatches, no, VarSet, Functor)
+    ),
+    Pieces = Pieces1 ++ Pieces2 ++ Pieces3 ++ Pieces4.
 
 %-----------------------------------------------------------------------------%
 
@@ -881,80 +834,85 @@
     typecheck_info_get_unify_context(Info, UnifyContext),
     get_type_stuff(TypeAssignSet0, Var, TypeStuffList),
     typecheck_info_get_varset(Info, VarSet),
-    write_context_and_pred_id(Info, !IO),
-    write_call_context(Context, PredMarkers, CalledPredId, ArgNum,
-        UnifyContext, !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  type error: ", !IO),
+
+    InClauseForPieces = in_clause_for_pieces(Info),
+    CallContextPieces = call_context_to_pieces(PredMarkers, CalledPredId,
+        ArgNum, UnifyContext),
+
+    Pieces1 = [words("type error:")],
     ( TypeStuffList = [SingleTypeStuff] ->
-        write_argument_name(VarSet, Var, !IO),
         SingleTypeStuff = type_stuff(VType, TVarSet, TBinding, HeadTypeParams),
-        io.write_string(" has type `", !IO),
-        write_type_b(VType, TVarSet, TBinding, HeadTypeParams, !IO),
-        io.write_string("',\n", !IO),
-        prog_out.write_context(Context, !IO),
-        io.write_string("  expected type was `", !IO),
-        write_type_b(Type, TVarSet, TBinding, HeadTypeParams, !IO),
-        io.write_string("'.\n", !IO)
-    ;
-        io.write_string("type of ", !IO),
-        write_argument_name(VarSet, Var, !IO),
-        io.write_string(" does not match its expected type;\n", !IO),
-
-        prog_out.write_context(Context, !IO),
-        io.write_string("  ", !IO),
-        write_argument_name(VarSet, Var, !IO),
-        io.write_string(" has overloaded actual/expected types {\n", !IO),
-
-        write_var_type_stuff_list(Context, TypeStuffList, Type, !IO),
-        io.write_string("\n", !IO),
-
-        prog_out.write_context(Context, !IO),
-        io.write_string("  }.\n", !IO)
-    ),
-    write_type_assign_set_msg(TypeAssignSet0, VarSet, !IO).
-
-report_error_arg_var(Info, Var, ArgTypeAssignSet0) -->
-    { typecheck_info_get_pred_markers(Info, PredMarkers) },
-    { typecheck_info_get_called_predid(Info, CalledPredId) },
-    { typecheck_info_get_arg_num(Info, ArgNum) },
-    { typecheck_info_get_context(Info, Context) },
-    { typecheck_info_get_unify_context(Info, UnifyContext) },
-    { get_arg_type_stuff(ArgTypeAssignSet0, Var, ArgTypeStuffList) },
-    { typecheck_info_get_varset(Info, VarSet) },
-    write_context_and_pred_id(Info),
-    write_call_context(Context, PredMarkers, CalledPredId, ArgNum,
-        UnifyContext),
-    prog_out.write_context(Context),
-    io.write_string("  type error: "),
-    ( { ArgTypeStuffList = [SingleArgTypeStuff] } ->
-        write_argument_name(VarSet, Var),
-        { SingleArgTypeStuff = arg_type_stuff(Type0, VType0, TVarSet,
-            HeadTypeParams) },
-        io.write_string(" has type `"),
-        output_type(VType0, TVarSet, HeadTypeParams),
-        io.write_string("',\n"),
-        prog_out.write_context(Context),
-        io.write_string("  expected type was `"),
-        output_type(Type0, TVarSet, HeadTypeParams),
-        io.write_string("'.\n")
-    ;
-        io.write_string("type of "),
-        write_argument_name(VarSet, Var),
-        io.write_string(" does not match its expected type;\n"),
-
-        prog_out.write_context(Context),
-        io.write_string("  "),
-        write_argument_name(VarSet, Var),
-        io.write_string(" has overloaded actual/expected types {\n"),
+        Pieces2 = argument_name_to_pieces(VarSet, Var) ++
+            [words("has type"), prefix("`")] ++
+            bound_type_to_pieces(VType, TVarSet, TBinding, HeadTypeParams) ++
+            [suffix("'"), suffix(","), nl,
+            words("expected type was"), prefix("`")] ++
+            bound_type_to_pieces(Type, TVarSet, TBinding, HeadTypeParams) ++
+            [suffix("'"), suffix("."), nl]
+    ;
+        Pieces2 = [words("type of")] ++
+            argument_name_to_pieces(VarSet, Var) ++
+            [words("does not match its expected type;"), nl] ++
+            argument_name_to_pieces(VarSet, Var) ++
+            [words("has overloaded actual/expected types {"), nl] ++
+            var_type_stuff_list_to_pieces(TypeStuffList, Type) ++
+            [nl, fixed("}."), nl]
+    ),
+
+    VerbosePieces = type_assign_set_msg_to_pieces(TypeAssignSet0, VarSet),
+    Msg = simple_msg(Context,
+        [always(InClauseForPieces ++ CallContextPieces),
+        always(Pieces1 ++ Pieces2),
+        verbose_only(VerbosePieces)]),
+    Spec = error_spec(severity_error, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
-        write_arg_type_stuff_list(Context, ArgTypeStuffList),
-        io.write_string("\n"),
+report_error_arg_var(Info, Var, ArgTypeAssignSet0, !IO) :-
+    typecheck_info_get_pred_markers(Info, PredMarkers),
+    typecheck_info_get_called_predid(Info, CalledPredId),
+    typecheck_info_get_arg_num(Info, ArgNum),
+    typecheck_info_get_context(Info, Context),
+    typecheck_info_get_unify_context(Info, UnifyContext),
+    get_arg_type_stuff(ArgTypeAssignSet0, Var, ArgTypeStuffList),
+    typecheck_info_get_varset(Info, VarSet),
 
-        prog_out.write_context(Context),
-        io.write_string("  }.\n")
-    ),
-    write_args_type_assign_set_msg(ArgTypeAssignSet0, VarSet).
+    InClauseForPieces = in_clause_for_pieces(Info),
+    CallContextPieces = call_context_to_pieces(PredMarkers, CalledPredId,
+        ArgNum, UnifyContext),
+
+    Pieces1 = [words("type error:")],
+    ( ArgTypeStuffList = [SingleArgTypeStuff] ->
+        SingleArgTypeStuff = arg_type_stuff(Type0, VType0, TVarSet,
+            HeadTypeParams),
+        Pieces2 = argument_name_to_pieces(VarSet, Var) ++
+            [words("has type"), prefix("`")] ++
+            type_to_pieces(VType0, TVarSet, HeadTypeParams) ++
+            [suffix("'"), suffix(","), nl,
+            words("expected type was"), prefix("`")] ++
+            type_to_pieces(Type0, TVarSet, HeadTypeParams) ++
+            [suffix("'"), suffix("."), nl]
+    ;
+        Pieces2 = [words("type of")] ++
+            argument_name_to_pieces(VarSet, Var) ++
+            [words("does not match its expected type;"), nl] ++
+            argument_name_to_pieces(VarSet, Var) ++
+            [words("has overloaded actual/expected types {"), nl] ++
+            arg_type_stuff_list_to_pieces(ArgTypeStuffList) ++
+            [nl, fixed("}."), nl]
+    ),
+
+    VerbosePieces = args_type_assign_set_msg_to_pieces(ArgTypeAssignSet0,
+        VarSet),
+    Msg = simple_msg(Context,
+        [always(InClauseForPieces ++ CallContextPieces),
+        always(Pieces1 ++ Pieces2),
+        verbose_only(VerbosePieces)]),
+    Spec = error_spec(severity_error, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 %-----------------------------------------------------------------------------%
 
@@ -964,229 +922,195 @@
     typecheck_info_get_arg_num(Info, ArgNum),
     typecheck_info_get_context(Info, Context),
     typecheck_info_get_unify_context(Info, UnifyContext),
-    write_context_and_pred_id(Info, !IO),
-    write_call_context(Context, PredMarkers, CalledPredId, ArgNum,
-        UnifyContext, !IO),
-    prog_out.write_context(Context, !IO),
-    %
-    % Check for some special cases, so that we can give
-    % clearer error messages.
-    %
-    (
-        Functor = cons(unqualified(Name), _),
-        language_builtin(Name, Arity)
-    ->
-        io.write_string("  error: the language construct ", !IO),
-        hlds_out.write_cons_id(Functor, !IO),
-        io.write_string(" should be\n", !IO),
-        prog_out.write_context(Context, !IO),
-        io.write_string("  used as a goal, not as an expression.\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string(
-        "  If you are trying to use a goal as a boolean function,\n", !IO),
-            prog_out.write_context(Context, !IO),
-            io.write_string(
-        "  you should write `if <goal> then yes else no' instead.\n", !IO),
-            ( Name = "call" ->
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  If you are trying to invoke a higher-order\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  function, you should use `apply', not `call'.\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  If you're trying to curry a higher-order predicate,\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  see the ""Creating higher-order terms"" section of the\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  Mercury Language Reference Manual.\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  If you really are trying to use `call' as an expression\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  and not as an application of the language builtin\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  call/N, make sure that you have the arity correct, and\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  that the functor `call' is actually defined (if it is\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  defined in a separate module, check that the module is\n", !IO),
-                prog_out.write_context(Context, !IO),
-                io.write_string(
-        "  correctly imported).\n", !IO)
-            ;
-                true
-            )
-        ;
-            VerboseErrors = no
-        )
-    ; Functor = cons(unqualified("else"), 2) ->
-        io.write_string("  error: unmatched `else'.\n", !IO)
-    ; Functor = cons(unqualified("if"), 2) ->
-        io.write_string("  error: `if' without `then' or `else'.\n", !IO)
-    ; Functor = cons(unqualified("then"), 2) ->
-        io.write_string("  error: `then' without `if' or `else'.\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string(
-                "  Note: the `else' part is not optional.\n", !IO),
-            prog_out.write_context(Context, !IO),
-            io.write_string(
-                "  Every if-then must have an `else'.\n", !IO)
-        ;
-            VerboseErrors = no
-        )
-    ; Functor = cons(unqualified("->"), 2) ->
-        io.write_string("  error: `->' without `;'.\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string(
-                "  Note: the else part is not optional.\n", !IO),
-            prog_out.write_context(Context, !IO),
-            io.write_string(
-                "  Every if-then must have an else.\n", !IO)
-        ;
-            VerboseErrors = no
-        )
-    ; Functor = cons(unqualified("^"), 2) ->
-        io.write_string("  error: invalid use of field selection " ++
-            "operator (`^').\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string("  This is probably some kind " ++
-                "of syntax error.\n", !IO),
-            prog_out.write_context(Context, !IO),
-            io.write_string("  The field name must be an " ++
-                "atom, not a variable or other term.\n", !IO)
-        ;
-            VerboseErrors = no
-        )
-    ; Functor = cons(unqualified(":="), 2) ->
-        io.write_string("  error: invalid use of field update " ++
-            "operator (`:=').\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string("  This is probably some kind " ++
-                "of syntax error.\n", !IO)
+    InClauseForPieces = in_clause_for_pieces(Info),
+    CallContextPieces = call_context_to_pieces(PredMarkers, CalledPredId,
+        ArgNum, UnifyContext),
+    InitComp = always(InClauseForPieces ++ CallContextPieces),
+
+    % Check for some special cases, so that we can give clearer error messages.
+    (
+        Functor = cons(unqualified(FunctorName), FunctorArity),
+        expect(unify(Arity, FunctorArity), this_file,
+            "report_error_undef_cons: arity mismatch"),
+        (
+            language_builtin_functor_components(FunctorName, Arity,
+                FunctorComps0)
+        ->
+            FunctorComps1 = FunctorComps0
         ;
-            VerboseErrors = no
-        )
-    ; Functor = cons(unqualified(":-"), 2) ->
-        io.write_string("  syntax error in lambda expression " ++
-            "(`:-').\n", !IO)
-    ; Functor = cons(unqualified("-->"), 2) ->
-        io.write_string("  syntax error in DCG lambda expression " ++
-            "(`-->').\n", !IO)
-    ; Functor = cons(unqualified("."), 2) ->
-        io.write_string("  error: the list constructor is " ++
-            "now `[|]/2', not `./2'.\n", !IO)
-    ; Functor = cons(unqualified("!"), 1) ->
-        io.write_string("  error: invalid use of `!' " ++
-            "state variable operator.\n", !IO),
-        globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-        (
-            VerboseErrors = yes,
-            prog_out.write_context(Context, !IO),
-            io.write_string("  You probably meant to use " ++
-                "`!.' or `!:'.\n", !IO)
+            syntax_functor_components(FunctorName, FunctorArity, FunctorComps0)
+        ->
+            FunctorComps1 = FunctorComps0
         ;
-            VerboseErrors = no
+            fail
         )
+    ->
+        FunctorComps = FunctorComps1,
+        ReportConsErrors = no
     ;
-        (
-            Functor = cons(Constructor, Arity),
+        Functor = cons(Constructor, FunctorArity),
+        expect(unify(Arity, FunctorArity), this_file,
+            "report_error_undef_cons: arity mismatch"),
             typecheck_info_get_ctors(Info, ConsTable),
             solutions.solutions(
                 (pred(N::out) is nondet :-
                     map.member(ConsTable, cons(Constructor, N), _),
                     N \= Arity
                 ), ActualArities),
-            ActualArities \= []
+        ActualArities = [_ | _]
         ->
-            report_wrong_arity_constructor(Constructor, Arity,
-                ActualArities, Context, !IO)
+        FunctorPieces = wrong_arity_constructor_to_pieces(Constructor, Arity,
+            ActualArities),
+        FunctorComps = [always(FunctorPieces)],
+        ReportConsErrors = yes
         ;
-            io.write_string("  error: undefined symbol `", !IO),
             strip_builtin_qualifier_from_cons_id(Functor, StrippedFunctor),
-            hlds_out.write_cons_id(StrippedFunctor, !IO),
-            io.write_string("'", !IO),
+        Pieces1 = [words("error: undefined symbol"),
+            quote(cons_id_to_string(StrippedFunctor))],
             (
                 Functor = cons(Constructor, _),
                 Constructor = qualified(ModQual, _)
             ->
-                maybe_report_missing_import(Info, ModQual, !IO)
+            Pieces2 = maybe_report_missing_import_addendum(Info, ModQual)
             ;
                 Functor = cons(unqualified("[|]"), 2)
             ->
-                maybe_report_missing_import(Info, unqualified("list"), !IO)
+            Pieces2 = maybe_report_missing_import_addendum(Info,
+                unqualified("list"))
             ;
-                io.write_string(".\n", !IO)
-            )
+            Pieces2 = [suffix("."), nl]
+        ),
+        FunctorComps = [always(Pieces1 ++ Pieces2)],
+        ReportConsErrors = yes
         ),
         (
-            ConsErrors = [_|_],
-            list.foldl(report_cons_error(Context), ConsErrors, !IO)
+        ReportConsErrors = yes,
+        ConsErrors = [_ | _]
+    ->
+        ConsMsgLists = list.map(report_cons_error(Context), ConsErrors),
+        list.condense(ConsMsgLists, ConsMsgs)
         ;
-            ConsErrors = []
-        )
-    ).
+        ConsMsgs = []
+    ),
+    Spec = error_spec(severity_error, phase_type_check,
+        [simple_msg(Context, [InitComp | FunctorComps]) | ConsMsgs]),
+    % XXX _NumErrors
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
+
+:- pred language_builtin_functor_components(string::in, arity::in,
+    list(error_msg_component)::out) is semidet.
 
-    % language_builtin(Name, Arity) is true iff Name/Arity is the name
+language_builtin_functor_components(Name, Arity, Components) :-
+    language_builtin_functor(Name, Arity),
+    MainPieces = [words("error: the language construct"),
+        sym_name_and_arity(unqualified(Name) / Arity),
+        words("should be used as a goal, not as an expression."), nl],
+    VerbosePieces = [words("If you are trying to use a goal"),
+        words("as a boolean function, you should write"),
+        words("`if <goal> then yes else no' instead."), nl],
+    ( Name = "call" ->
+        VerboseCallPieces =
+            [words("If you are trying to invoke"),
+            words("a higher-order function,"),
+            words("you should use `apply', not `call'."), nl,
+            words("If you're trying to curry"),
+            words("a higher-order predicate,"),
+            words("see the ""Creating higher-order terms"" section of"),
+            words("the Mercury Language Reference Manual."), nl,
+            words("If you really are trying to use `call'"),
+            words("as an expression and not as an application of"),
+            words("the language builtin call/N, make sure that"),
+            words("you have the arity correct, and that the functor"),
+            words("`call' is actually defined (if it is defined"),
+            words("in a separate module, check that the module is"),
+            words("correctly imported)."), nl]
+    ;
+        VerboseCallPieces = []
+    ),
+    Components = [always(MainPieces),
+        verbose_only(VerbosePieces ++ VerboseCallPieces)].
+
+    % language_builtin_functor(Name, Arity) is true iff Name/Arity is the name
     % of a builtin language construct that should be used as a goal,
     % not as an expression.
     %
-:- pred language_builtin(string::in, arity::in) is semidet.
+:- pred language_builtin_functor(string::in, arity::in) is semidet.
 
-language_builtin("=", 2).
-language_builtin("\\=", 2).
-language_builtin(",", 2).
-language_builtin(";", 2).
-language_builtin("\\+", 1).
-language_builtin("not", 1).
-language_builtin("<=>", 2).
-language_builtin("=>", 2).
-language_builtin("<=", 2).
-language_builtin("call", _).
-language_builtin("impure", 1).
-language_builtin("semipure", 1).
-language_builtin("all", 2).
-language_builtin("some", 2).
+language_builtin_functor("=", 2).
+language_builtin_functor("\\=", 2).
+language_builtin_functor(",", 2).
+language_builtin_functor(";", 2).
+language_builtin_functor("\\+", 1).
+language_builtin_functor("not", 1).
+language_builtin_functor("<=>", 2).
+language_builtin_functor("=>", 2).
+language_builtin_functor("<=", 2).
+language_builtin_functor("call", _).
+language_builtin_functor("impure", 1).
+language_builtin_functor("semipure", 1).
+language_builtin_functor("all", 2).
+language_builtin_functor("some", 2).
+
+:- pred syntax_functor_components(string::in, arity::in,
+    list(error_msg_component)::out) is semidet.
+
+syntax_functor_components("else", 2, Components) :-
+    Pieces = [words("error: unmatched `else'."), nl],
+    Components = [always(Pieces)].
+syntax_functor_components("if", 2, Components) :-
+    Pieces = [words("error: `if' without `then' or `else'."), nl],
+    Components = [always(Pieces)].
+syntax_functor_components("then", 2, Components) :-
+    Pieces1 = [words("error: `then' without `if' or `else'."), nl],
+    Pieces2 = [words("Note: the `else' part is not optional."),
+        words("Every if-then must have an `else'."), nl],
+    Components = [always(Pieces1), verbose_only(Pieces2)].
+syntax_functor_components("->", 2, Components) :-
+    Pieces1 = [words("error: `->' without `;'."), nl],
+    Pieces2 = [words("Note: the else part is not optional."),
+        words("Every if-then must have an else."), nl],
+    Components = [always(Pieces1), verbose_only(Pieces2)].
+syntax_functor_components("^", 2, Components) :-
+    Pieces1 =
+        [words("error: invalid use of field selection operator (`^')."), nl],
+    Pieces2 = [words("This is probably some kind of syntax error."),
+        words("The field name must be an atom,"),
+        words("not a variable or other term."), nl],
+    Components = [always(Pieces1), verbose_only(Pieces2)].
+syntax_functor_components(":=", 2, Components) :-
+    Pieces1 = [words("error: invalid use of field update operator"),
+        words("(`:=')."), nl],
+    Pieces2 = [words("This is probably some kind of syntax error."), nl],
+    Components = [always(Pieces1), verbose_only(Pieces2)].
+syntax_functor_components(":-", 2, Components) :-
+    Pieces = [words("syntax error in lambda expression (`:-')."), nl],
+    Components = [always(Pieces)].
+syntax_functor_components("-->", 2, Components) :-
+    Pieces = [words("syntax error in DCG lambda expression (`-->')."), nl],
+    Components = [always(Pieces)].
+syntax_functor_components(".", 2, Components) :-
+    Pieces =
+        [words("error: the list constructor is now `[|]/2', not `./2'."), nl],
+    Components = [always(Pieces)].
+syntax_functor_components("!", 1, Components) :-
+    Pieces1 =
+        [words("error: invalid use of `!' state variable operator."), nl],
+    Pieces2 = [words("You probably meant to use `!.' or `!:'."), nl],
+    Components = [always(Pieces1), verbose_only(Pieces2)].
 
-:- pred report_wrong_arity_constructor(sym_name::in, arity::in, list(int)::in,
-    prog_context::in, io::di, io::uo) is det.
+:- func wrong_arity_constructor_to_pieces(sym_name, arity, list(int))
+    = list(format_component).
 
-report_wrong_arity_constructor(Name, Arity, ActualArities, Context, !IO) :-
-    io.write_string("  error: ", !IO),
+wrong_arity_constructor_to_pieces(Name, Arity, ActualArities) = Pieces :-
     MaybePredOrFunc = no,
-    report_error_num_args(MaybePredOrFunc, Arity, ActualArities, !IO),
-    io.nl(!IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  in use of constructor `", !IO),
-    prog_out.write_sym_name(Name, !IO),
-    io.write_string("'.\n", !IO).
+    NumArgsPieces = error_num_args_to_pieces(MaybePredOrFunc, Arity,
+        ActualArities),
+    Pieces = [words("error: ")] ++ NumArgsPieces ++
+        [words("in use of constructor"), sym_name(Name), suffix(".")].
 
-:- pred report_cons_error(prog_context::in, cons_error::in, io::di, io::uo)
-    is det.
+:- func report_cons_error(prog_context, cons_error) = list(error_msg).
 
-report_cons_error(Context, ConsError, !IO) :-
+report_cons_error(Context, ConsError) = Msgs :-
     (
         ConsError = foreign_type_constructor(TypeCtor, _),
         TypeCtor = type_ctor(TypeName, TypeArity),
@@ -1199,44 +1123,39 @@
             words("in all predicates and functions"),
             words("which are not implemented"),
             words("for those foreign types.")],
-        write_error_pieces_not_first_line(Context, 0, Pieces, !IO)
+        Msgs = [simple_msg(Context, [always(Pieces)])]
     ;
-        ConsError = abstract_imported_type
+        ConsError = abstract_imported_type,
         % For `abstract_imported_type' errors, the "undefined symbol"
         % error written by `report_error_undef_cons' is sufficient so
         % we do not print an additional error message here.
+        Msgs = []
     ;
-        ConsError = invalid_field_update(FieldName, FieldDefn,
-            TVarSet, TVars),
+        ConsError = invalid_field_update(FieldName, FieldDefn, TVarSet, TVars),
         FieldDefn = hlds_ctor_field_defn(DefnContext, _, _, ConsId, _),
         Pieces1 = [words("Field"), sym_name(FieldName),
             words("cannot be updated because"),
             words("the existentially quantified type")],
         (
             TVars = [],
-            unexpected(this_file, "report_invalid_field_update:"
-                ++ " no type variables")
+            unexpected(this_file,
+                "report_invalid_field_update: no type variables")
         ;
             TVars = [TVar],
             TVarsStr = mercury_var_to_string(TVar, TVarSet, no),
-            Pieces2 = [words("variable"),
-                words("`" ++ TVarsStr ++ "'"),
-                words("occurs")]
+            Pieces2 = [words("variable"), quote(TVarsStr), words("occurs")]
         ;
             TVars = [_, _ | _],
             TVarsStr = mercury_vars_to_string(TVars, TVarSet, no),
-            Pieces2 = [words("variables"),
-                words("`" ++ TVarsStr ++ "'"),
-                words("occur")]
+            Pieces2 = [words("variables"), quote(TVarsStr), words("occur")]
         ),
         ConsIdStr = cons_id_to_string(ConsId),
-        Pieces3 = [words("in the types of field"),
-            sym_name(FieldName),
+        Pieces3 = [words("in the types of field"), sym_name(FieldName),
             words("and some other field"),
             words("in definition of constructor"),
             fixed("`" ++ ConsIdStr ++ "'.")],
         Pieces = Pieces1 ++ Pieces2 ++ Pieces3,
-        write_error_pieces_not_first_line(DefnContext, 0, Pieces, !IO)
+        Msgs = [simple_msg(DefnContext, [always(Pieces)])]
     ;
         ConsError = new_on_non_existential_type(TypeCtor),
         TypeCtor = type_ctor(TypeName, TypeArity),
@@ -1244,44 +1163,59 @@
             words("on a constructor of type"),
             sym_name_and_arity(TypeName / TypeArity),
             words("which is not existentially typed.")],
-        write_error_pieces_not_first_line(Context, 0, Pieces, !IO)
+        Msgs = [simple_msg(Context, [always(Pieces)])]
     ).
 
 %-----------------------------------------------------------------------------%
 
 report_ambiguity_error(Info, TypeAssign1, TypeAssign2, !IO) :-
-    write_typecheck_info_context(Info, !IO),
-    io.write_string(
-        "  error: ambiguous overloading causes type ambiguity.\n", !IO),
+    InClauseForPieces = in_clause_for_pieces(Info),
+    Pieces1 =
+        [words("error: ambiguous overloading causes type ambiguity."), nl],
     typecheck_info_get_varset(Info, VarSet),
     type_assign_get_var_types(TypeAssign1, VarTypes1),
     map.keys(VarTypes1, Vars1),
-    report_ambiguity_error_2(Vars1, VarSet, Info, TypeAssign1, TypeAssign2,
-        no, Found, !IO),
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    ( Found = no ->
-        report_warning_too_much_overloading(Info, !IO)
-    ; VerboseErrors = yes ->
-        io.write_strings([
-"\tYou will need to add an explicit type qualification to resolve the\n",
-"\ttype ambiguity.\n",
-"\tThe way to add an explicit type qualification is to use ""with_type"".\n",
-"\tFor details see the ""Explicit type qualification"" sub-section\n",
-"\tof the ""Data-terms"" section of the ""Syntax"" chapter\n",
-"\tof the Mercury language reference manual.\n"
-        ], !IO)
-    ;
-        true
-    ).
-
-:- pred report_ambiguity_error_2(list(prog_var)::in, prog_varset::in,
-    typecheck_info::in, type_assign::in, type_assign::in,
-    bool::in, bool::out, io::di, io::uo) is det.
-
-report_ambiguity_error_2([], _VarSet, _, _TypeAssign1, _TypeAssign2,
-        !Found, !IO).
-report_ambiguity_error_2([V | Vs], VarSet, Info, TypeAssign1,
-        TypeAssign2, !Found, !IO) :-
+    AmbiguityPieces = ambiguity_error_possibilities_to_pieces(Vars1, VarSet,
+        TypeAssign1, TypeAssign2),
+    (
+        AmbiguityPieces = [],
+        Pieces2 = [],
+        VerboseComponents = [],
+        WarningMsgs = warning_too_much_overloading_to_msgs(Info)
+    ;
+        AmbiguityPieces = [_ | _],
+        Pieces2 = [words("Possible type assignments include:"), nl
+            | AmbiguityPieces],
+        VerboseComponents = [verbose_only([words(add_qualifiers_reminder)])],
+        WarningMsgs = []
+    ),
+
+    typecheck_info_get_context(Info, Context),
+    MainMsg = simple_msg(Context,
+        [always(InClauseForPieces ++ Pieces1 ++ Pieces2) | VerboseComponents]),
+    Spec = error_spec(severity_error, phase_type_check,
+        [MainMsg | WarningMsgs]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
+
+:- func add_qualifiers_reminder = string.
+
+add_qualifiers_reminder =
+    "You will need to add an explicit type qualification" ++
+    "to resolve the type ambiguity." ++
+    "The way to add an explicit type qualification is to use ""with_type""." ++
+    "For details see the ""Explicit type qualification"" sub-section" ++
+    "of the ""Data-terms"" section of the ""Syntax"" chapter" ++
+    "of the Mercury language reference manual.".
+
+:- func ambiguity_error_possibilities_to_pieces(list(prog_var), prog_varset,
+    type_assign, type_assign) = list(format_component).
+
+ambiguity_error_possibilities_to_pieces([], _VarSet,
+        _TypeAssign1, _TypeAssign2) = [].
+ambiguity_error_possibilities_to_pieces([Var | Vars], VarSet,
+        TypeAssign1, TypeAssign2) = Pieces :-
     type_assign_get_var_types(TypeAssign1, VarTypes1),
     type_assign_get_var_types(TypeAssign2, VarTypes2),
     type_assign_get_type_bindings(TypeAssign1, TypeBindings1),
@@ -1289,53 +1223,52 @@
     type_assign_get_head_type_params(TypeAssign1, HeadTypeParams1),
     type_assign_get_head_type_params(TypeAssign2, HeadTypeParams2),
     (
-        map.search(VarTypes1, V, Type1),
-        map.search(VarTypes2, V, Type2),
+        map.search(VarTypes1, Var, Type1),
+        map.search(VarTypes2, Var, Type2),
         apply_rec_subst_to_type(TypeBindings1, Type1, T1),
         apply_rec_subst_to_type(TypeBindings2, Type2, T2),
         \+ identical_types(T1, T2)
     ->
-        typecheck_info_get_context(Info, Context),
-        (
-            !.Found = no,
-            prog_out.write_context(Context, !IO),
-            io.write_string("  Possible type assignments include:\n", !IO)
-        ;
-            !.Found = yes
-        ),
-        !:Found = yes,
-        prog_out.write_context(Context, !IO),
-        mercury_output_var(V, VarSet, no, !IO),
-        io.write_string(": ", !IO),
         type_assign_get_typevarset(TypeAssign1, TVarSet1),
-        output_type(T1, TVarSet1, HeadTypeParams1, !IO),
-        io.write_string(" or ", !IO),
         type_assign_get_typevarset(TypeAssign2, TVarSet2),
-        output_type(T2, TVarSet2, HeadTypeParams2, !IO),
-        io.write_string("\n", !IO)
-    ;
-        true
-    ),
-    report_ambiguity_error_2(Vs, VarSet, Info, TypeAssign1, TypeAssign2,
-        !Found, !IO).
+        HeadPieces =
+            [words(mercury_var_to_string(Var, VarSet, no)), suffix(":")] ++
+            type_to_pieces(T1, TVarSet1, HeadTypeParams1) ++ [words("or")] ++
+            type_to_pieces(T2, TVarSet2, HeadTypeParams2) ++ [nl]
+    ;
+        HeadPieces = []
+    ),
+    TailPieces = ambiguity_error_possibilities_to_pieces(Vars, VarSet,
+        TypeAssign1, TypeAssign2),
+    Pieces = HeadPieces ++ TailPieces.
 
 %-----------------------------------------------------------------------------%
 
 report_unsatisfiable_constraints(TypeAssignSet, !Info, !IO) :-
+    InClauseForPieces = in_clause_for_pieces(!.Info),
+    list.map_foldl(constraints_to_pieces, TypeAssignSet, ConstraintPieceLists,
+        0, NumUnsatisfied),
+    ( NumUnsatisfied = 1 ->
+        Pieces1 = [words("unsatisfiable typeclass constraint:"), nl]
+    ;
+        Pieces1 = [words("unsatisfiable typeclass constraints:"), nl]
+    ),
+    % XXX this won't be very pretty when there are multiple type_assigns.
+    Pieces2 = component_list_to_line_pieces(ConstraintPieceLists,
+        [suffix(".")]),
+
     typecheck_info_get_context(!.Info, Context),
-    write_context_and_pred_id(!.Info, !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  unsatisfiable typeclass constraint(s):\n", !IO),
-
-        % XXX this won't be very pretty when there are
-        % XXX multiple type_assigns.
-    io.write_list(TypeAssignSet, "\n", write_constraints(Context), !IO),
-    typecheck_info_set_found_error(yes, !Info).
+    Msg = simple_msg(Context,
+        [always(InClauseForPieces ++ Pieces1 ++ Pieces2)]),
+    Spec = error_spec(severity_error, phase_type_check, [Msg]),
+    % XXX _NumErrors
+    typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
-:- pred write_constraints(prog_context::in, type_assign::in, io::di, io::uo)
-    is det.
+:- pred constraints_to_pieces(type_assign::in, list(format_component)::out,
+    int::in, int::out) is det.
 
-write_constraints(Context, TypeAssign, !IO) :-
+constraints_to_pieces(TypeAssign, Pieces, !NumUnsatisfied) :-
     type_assign_get_typeclass_constraints(TypeAssign, Constraints),
     UnprovenConstraints = Constraints ^ unproven,
     retrieve_prog_constraint_list(UnprovenConstraints,
@@ -1347,12 +1280,17 @@
         UnprovenProgConstraints0, UnprovenProgConstraints1),
     list.sort_and_remove_dups(UnprovenProgConstraints1,
         UnprovenProgConstraints),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  `", !IO),
-    AppendVarnums = no,
-    io.write_list(UnprovenProgConstraints, "', `",
-        mercury_output_constraint(VarSet, AppendVarnums), !IO),
-    io.write_string("'.\n", !IO).
+    !:NumUnsatisfied = !.NumUnsatisfied + list.length(UnprovenProgConstraints),
+    UnprovenProgConstraintStrings =
+        list.map(mercury_constraint_to_string(VarSet),
+            UnprovenProgConstraints),
+    UnprovenProgConstraintsPieces =
+        list.map(wrap_quote, UnprovenProgConstraintStrings),
+    Pieces = component_list_to_pieces(UnprovenProgConstraintsPieces).
+
+:- func wrap_quote(string) = format_component.
+
+wrap_quote(Str) = quote(Str).
 
 %-----------------------------------------------------------------------------%
 
@@ -1365,299 +1303,288 @@
             PredId)] ++
         [words("should define the variable"),
         fixed(add_quotes(VarName)), suffix(".")],
-    write_error_pieces(Context, 0, Pieces, !IO),
-    io.set_exit_status(1, !IO).
+    Spec = error_spec(severity_error, phase_type_check,
+        [simple_msg(Context, [always(Pieces)])]),
+    % XXX _NumErrors
+    % typecheck_info_set_found_error(yes, !Info),
+    write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO).
 
 %-----------------------------------------------------------------------------%
 
-:- pred write_types_of_vars(list(prog_var)::in, prog_varset::in,
-    prog_context::in, typecheck_info::in, type_assign_set::in,
-    io::di, io::uo) is det.
+:- func types_of_vars_to_pieces(list(prog_var), prog_varset,
+    typecheck_info, type_assign_set) = list(format_component).
 
-write_types_of_vars([], _, _, _, _, !IO) :-
-    io.write_string(".\n", !IO).
-write_types_of_vars([Var | Vars], VarSet, Context, Info, TypeAssignSet, !IO) :-
-    io.write_string(",\n", !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("  ", !IO),
-    write_argument_name(VarSet, Var, !IO),
-    write_type_of_var(Info, Context, TypeAssignSet, Var, !IO),
-    write_types_of_vars(Vars, VarSet, Context, Info, TypeAssignSet, !IO).
+types_of_vars_to_pieces([], _, _, _) = [suffix("."), nl].
+types_of_vars_to_pieces([Var | Vars], VarSet, Info, TypeAssignSet) =
+    [suffix(","), nl] ++
+    argument_name_to_pieces(VarSet, Var) ++
+    type_of_var_to_pieces(TypeAssignSet, Var) ++
+    types_of_vars_to_pieces(Vars, VarSet, Info, TypeAssignSet).
 
-:- pred write_argument_name(prog_varset::in, prog_var::in, io::di, io::uo)
-    is det.
+:- func argument_name_to_pieces(prog_varset, prog_var)
+    = list(format_component).
 
-write_argument_name(VarSet, Var, !IO) :-
+argument_name_to_pieces(VarSet, Var) = Pieces :-
     ( varset.search_name(VarSet, Var, _) ->
-        io.write_string("variable `", !IO),
-        mercury_output_var(Var, VarSet, no, !IO),
-        io.write_string("'", !IO)
+        Pieces = [words("variable"),
+            quote(mercury_var_to_string(Var, VarSet, no))]
     ;
-        io.write_string("argument", !IO)
+        Pieces = [words("argument")]
     ).
 
-:- pred write_functor_name(cons_id::in, int::in, io::di, io::uo) is det.
+:- func functor_name_to_pieces(cons_id, arity) = list(format_component).
 
-write_functor_name(Functor, Arity, !IO) :-
+functor_name_to_pieces(Functor, Arity) = Pieces :-
     strip_builtin_qualifier_from_cons_id(Functor, StrippedFunctor),
     ( Arity = 0 ->
-        io.write_string("constant `", !IO),
+        Piece1 = words("constant"),
         ( Functor = cons(Name, _) ->
-            prog_out.write_sym_name(Name, !IO)
+            Piece2 = sym_name(Name)
         ;
-            hlds_out.write_cons_id(StrippedFunctor, !IO)
+            Piece2 = quote(cons_id_to_string(StrippedFunctor))
         ),
-        io.write_string("'", !IO)
+        Pieces = [Piece1, Piece2]
     ; Functor = cons(unqualified(""), _) ->
-        io.write_string("higher-order term (with arity ", !IO),
-        io.write_int(Arity - 1, !IO),
-        io.write_string(")", !IO)
+        Pieces = [words("higher-order term (with arity"),
+            int_fixed(Arity - 1), suffix(")")]
     ;
-        io.write_string("functor `", !IO),
-        hlds_out.write_cons_id(StrippedFunctor, !IO),
-        io.write_string("'", !IO)
+        Pieces = [words("functor"), quote(cons_id_to_string(StrippedFunctor))]
     ).
 
-:- pred write_type_of_var(typecheck_info::in, prog_context::in,
-    type_assign_set::in, prog_var::in, io::di, io::uo) is det.
+:- func type_of_var_to_pieces(type_assign_set, prog_var)
+    = list(format_component).
 
-write_type_of_var(_Info, Context, TypeAssignSet, Var, !IO) :-
+type_of_var_to_pieces(TypeAssignSet, Var) = Pieces :-
     get_type_stuff(TypeAssignSet, Var, TypeStuffList),
     TypeStrs0 = list.map(typestuff_to_typestr, TypeStuffList),
     list.sort_and_remove_dups(TypeStrs0, TypeStrs),
     ( TypeStrs = [TypeStr] ->
-        io.write_string(" has type `", !IO),
-        io.write_string(TypeStr, !IO),
-        io.write_string("'", !IO)
+        Pieces = [words("has type"), quote(TypeStr)]
     ;
-        io.write_string(" has overloaded type {\n", !IO),
-        write_types_list(Context, TypeStrs, !IO),
-        prog_out.write_context(Context, !IO),
-        io.write_string("  }", !IO)
+        Pieces = [words("has overloaded type {"), nl_indent_delta(2)] ++
+            types_list_to_pieces(TypeStrs) ++ [nl_indent_delta(-2), words("}")]
     ).
 
-:- pred write_type_of_functor(cons_id::in, int::in, prog_context::in,
-    list(cons_type_info)::in, io::di, io::uo) is det.
+:- func type_of_functor_to_pieces(cons_id, int, list(cons_type_info))
+    = list(format_component).
 
-write_type_of_functor(Functor, Arity, Context, ConsDefnList, !IO) :-
+type_of_functor_to_pieces(Functor, Arity, ConsDefnList) = Pieces :-
     ( ConsDefnList = [SingleDefn] ->
-        io.write_string(" has type ", !IO),
         ( Arity \= 0 ->
-            io.write_string("\n", !IO),
-            prog_out.write_context(Context, !IO),
-            io.write_string("  `", !IO)
+            SepPieces = [nl]
         ;
-            io.write_string("`", !IO)
+            SepPieces = []
         ),
-        write_cons_type(SingleDefn, Functor, Context, !IO),
-        io.write_string("'", !IO)
+        ConsTypePieces = cons_type_to_pieces(SingleDefn, Functor),
+        Pieces = [words("has type")] ++ SepPieces ++
+            [prefix("`")] ++ ConsTypePieces ++ [suffix("'")]
     ;
-        io.write_string(" has overloaded type\n", !IO),
-        prog_out.write_context(Context, !IO),
-        io.write_string("  { ", !IO),
-        write_cons_type_list(ConsDefnList, Functor, Arity, Context, !IO),
-        io.write_string(" }", !IO)
+        ConsTypeListPieces =
+            cons_type_list_to_pieces(ConsDefnList, Functor, Arity),
+        Pieces = [words("has overloaded type"), nl_indent_delta(1)] ++
+            [fixed("{")] ++ ConsTypeListPieces ++
+            [nl_indent_delta(-1), fixed("}")]
     ).
 
-:- pred write_cons_type(cons_type_info::in, cons_id::in, prog_context::in,
-    io::di, io::uo) is det.
+    % Return a description of the given data constructor's argument types.
+    %
+    % The caller should ensure that these pieces are indented one or two levels
+    % to separate them from surrounding material.
+    %
+:- func cons_type_to_pieces(cons_type_info, cons_id) = list(format_component).
 
-    % XXX Should we mention the context here?
-write_cons_type(ConsInfo, Functor, _, !IO) :-
+cons_type_to_pieces(ConsInfo, Functor) = Pieces :-
     ConsInfo = cons_type_info(TVarSet, ExistQVars, ConsType, ArgTypes, _, _),
     (
         ArgTypes = [_ | _],
-        (
-            Functor = cons(SymName, _Arity)
-        ->
+        ( Functor = cons(SymName, _Arity) ->
+            % What we construct in Type is not really a type: it is a
+            % function symbol applied to a list of argument types. However
+            % *syntactically*, it looks like a type, and we already have
+            % code to print types, so we take a shortcut.
             Type = defined_type(SymName, ArgTypes, kind_star),
-            output_type(Type, TVarSet, ExistQVars, !IO)
+            ArgPieces = type_to_pieces(Type, TVarSet, ExistQVars) ++
+                [suffix(":")]
         ;
-            unexpected(this_file, "write_cons_type: invalid cons_id")
-        ),
-        io.write_string(": ", !IO)
+            unexpected(this_file, "cons_type_to_pieces: invalid cons_id")
+        )
     ;
-        ArgTypes = []
+        ArgTypes = [],
+        ArgPieces = []
     ),
-    output_type(ConsType, TVarSet, ExistQVars, !IO).
+    Pieces = ArgPieces ++ type_to_pieces(ConsType, TVarSet, ExistQVars).
 
-:- pred write_cons_type_list(list(cons_type_info)::in, cons_id::in, int::in,
-    prog_context::in, io::di, io::uo) is det.
+    % Return a description of the  argument types of the given list of
+    % data constructors.
+    %
+    % The caller should ensure that these pieces are indented one or two levels
+    % to separate them from surrounding material.
+    %
+:- func cons_type_list_to_pieces(list(cons_type_info), cons_id, int)
+    = list(format_component).
 
-write_cons_type_list([], _, _, _, !IO).
-write_cons_type_list([ConsDefn | ConsDefns], Functor, Arity, Context, !IO) :-
-    write_cons_type(ConsDefn, Functor, Context, !IO),
+cons_type_list_to_pieces([], _, _) = [].
+cons_type_list_to_pieces([ConsDefn | ConsDefns], Functor, Arity) = Pieces :-
+    ThisPieces = cons_type_to_pieces(ConsDefn, Functor),
     (
-        ConsDefns = []
+        ConsDefns = [],
+        Pieces = ThisPieces
     ;
         ConsDefns = [_ | _],
         ( Arity = 0 ->
-            io.write_string(", ", !IO)
+            ConnectPieces = [suffix(",")]
         ;
-            io.write_string(",\n", !IO),
-            prog_out.write_context(Context, !IO),
-            io.write_string("  ", !IO)
+            ConnectPieces = [suffix(","), nl]
         ),
-        write_cons_type_list(ConsDefns, Functor, Arity, Context, !IO)
+        TailPieces = cons_type_list_to_pieces(ConsDefns, Functor, Arity),
+        Pieces = ThisPieces ++ ConnectPieces ++ TailPieces
     ).
 
-:- pred write_type_assign_set_msg(type_assign_set::in, prog_varset::in,
-    io::di, io::uo) is det.
+    % Return a description of the current set of type assignments.
+    %
+    % Since this description can be very large and unwieldy, containing
+    % much irrelevant information as well as (hopefully) one or two useful
+    % pieces of information, it is intended to be used only with
+    % --verbose-errors.
+    %
+:- func type_assign_set_msg_to_pieces(type_assign_set, prog_varset)
+    = list(format_component).
 
-write_type_assign_set_msg(TypeAssignSet, VarSet, !IO) :-
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
+type_assign_set_msg_to_pieces(TypeAssignSet, VarSet) = Pieces :-
         ( TypeAssignSet = [_] ->
-            io.write_string(
-                "\tThe partial type assignment was:\n", !IO)
+        FirstWords = "The partial type assignment was:",
+        MaybeSeq = no
         ;
-            io.write_string("\tThe possible partial type " ++
-                "assignments were:\n", !IO)
+        FirstWords = "The possible partial type assignments were:",
+        MaybeSeq = yes(1)
         ),
-        write_type_assign_set(TypeAssignSet, VarSet, !IO)
-    ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO)
-    ).
+    LaterPieces = type_assign_set_to_pieces(TypeAssignSet, MaybeSeq, VarSet),
+    Pieces = [words(FirstWords), nl_indent_delta(1) | LaterPieces] ++
+        [nl_indent_delta(-1)].
 
-:- pred write_args_type_assign_set_msg(args_type_assign_set::in,
-    prog_varset::in, io::di, io::uo) is det.
+    % Return a description of the current set of type assignments.
+    %
+    % Since this description can be very large and unwieldy, containing
+    % much irrelevant information as well as (hopefully) one or two useful
+    % pieces of information, it is intended to be used only with
+    % --verbose-errors.
+    %
+:- func args_type_assign_set_msg_to_pieces(args_type_assign_set, prog_varset)
+    = list(format_component).
 
-write_args_type_assign_set_msg(ArgTypeAssignSet, VarSet, !IO) :-
-    globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
-    (
-        VerboseErrors = yes,
+args_type_assign_set_msg_to_pieces(ArgTypeAssignSet, VarSet) = Pieces :-
         ( ArgTypeAssignSet = [_] ->
-            io.write_string(
-                "\tThe partial type assignment was:\n", !IO)
+        FirstWords = "The partial type assignment was:",
+        MaybeSeq = no
         ;
-            io.write_string("\tThe possible partial type " ++
-                "assignments were:\n", !IO)
+        FirstWords = "The possible partial type assignments were:",
+        MaybeSeq = yes(1)
         ),
-        write_args_type_assign_set(ArgTypeAssignSet, VarSet, !IO)
-    ;
-        VerboseErrors = no,
-        globals.io_set_extra_error_info(yes, !IO)
-    ).
+    LaterPieces = args_type_assign_set_to_pieces(ArgTypeAssignSet, MaybeSeq,
+        VarSet),
+    Pieces = [words(FirstWords), nl_indent_delta(1) | LaterPieces] ++
+        [nl_indent_delta(-1)].
 
-:- pred output_type(mer_type::in, tvarset::in, head_type_params::in,
-    io::di, io::uo) is det.
+:- func type_to_pieces(mer_type, tvarset, head_type_params)
+    = list(format_component).
 
-output_type(Type0, TVarSet, HeadTypeParams, !IO) :-
+type_to_pieces(Type0, TVarSet, HeadTypeParams) = Pieces :-
     strip_builtin_qualifiers_from_type(Type0, Type),
     unparse_type(Type, Term0),
     list.map(term.coerce_var, HeadTypeParams, ExistQVars),
     maybe_add_existential_quantifier(ExistQVars, Term0, Term),
     varset.coerce(TVarSet, VarSet),
-    mercury_output_term(Term, VarSet, no, !IO).
+    Pieces = [words(mercury_term_to_string(Term, VarSet, no))].
 
-:- pred write_types_list(prog_context::in, list(string)::in,
-    io::di, io::uo) is det.
+    % Return a description of the given list of types.
+    %
+    % The caller should ensure that these pieces are indented one or two levels
+    % to separate them from surrounding material.
+    %
+:- func types_list_to_pieces(list(string)) = list(format_component).
 
-write_types_list(_Context, [], !IO).
-write_types_list(Context, [Type | Types], !IO) :-
-    prog_out.write_context(Context, !IO),
-    io.write_string("    ", !IO),
-    io.write_string(Type, !IO),
-    (
-        Types = [],
-        io.write_string("\n", !IO)
-    ;
-        Types = [_ | _],
-        io.write_string(",\n", !IO),
-        write_types_list(Context, Types, !IO)
-    ).
+types_list_to_pieces(TypeStrs) =
+    component_list_to_line_pieces(list.map(string_to_pieces, TypeStrs), []).
 
-:- pred write_type_stuff(type_stuff::in, io::di, io::uo) is det.
+:- func string_to_pieces(string) = list(format_component).
 
-write_type_stuff(type_stuff(Type, TVarSet, TypeBinding, HeadTypeParams),
-        !IO) :-
-    write_type_b(Type, TVarSet, TypeBinding, HeadTypeParams, !IO).
+string_to_pieces(Str) = [words(Str)].
 
-:- pred write_var_type_stuff_list(prog_context::in, list(type_stuff)::in,
-    mer_type::in, io::di, io::uo) is det.
+:- func var_type_stuff_list_to_pieces(list(type_stuff), mer_type)
+    = list(format_component).
 
-write_var_type_stuff_list(Context, TypeStuffs, Type, !IO) :-
-    io.write_list(TypeStuffs, ",\n", write_var_type_stuff(Context, Type),
-        !IO).
+var_type_stuff_list_to_pieces(TypeStuffs, Type) =
+    component_list_to_line_pieces(
+        list.map(var_type_stuff_to_pieces(Type), TypeStuffs), []).
 
-:- pred write_var_type_stuff(prog_context::in, mer_type::in, type_stuff::in,
-    io::di, io::uo) is det.
+    % Return a description of the given list of types.
+    %
+    % The caller should ensure that these pieces are indented one or two levels
+    % to separate them from surrounding material.
+    %
+:- func var_type_stuff_to_pieces(mer_type, type_stuff)
+    = list(format_component).
 
-write_var_type_stuff(Context, Type, VarTypeStuff, !IO) :-
+var_type_stuff_to_pieces(Type, VarTypeStuff) = Pieces :-
     VarTypeStuff = type_stuff(VarType, TVarSet, TypeBinding, HeadTypeParams),
-    prog_out.write_context(Context, !IO),
-    io.write_string("    (inferred) ", !IO),
-    write_type_b(VarType, TVarSet, TypeBinding, HeadTypeParams, !IO),
-    io.write_string(",\n", !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("    (expected) ", !IO),
-    write_type_b(Type, TVarSet, TypeBinding, HeadTypeParams, !IO).
+    Pieces = [words("(inferred)")] ++
+        bound_type_to_pieces(VarType, TVarSet, TypeBinding, HeadTypeParams) ++
+        [suffix(","), nl, words("(expected)")] ++
+        bound_type_to_pieces(Type, TVarSet, TypeBinding, HeadTypeParams).
 
-:- pred write_type_b(mer_type::in, tvarset::in, tsubst::in,
-    head_type_params::in, io::di, io::uo) is det.
+:- func bound_type_to_pieces(mer_type, tvarset, tsubst, head_type_params)
+    = list(format_component).
 
-write_type_b(Type0, TypeVarSet, TypeBindings, HeadTypeParams, !IO) :-
+bound_type_to_pieces(Type0, TypeVarSet, TypeBindings, HeadTypeParams)
+        = Pieces :-
     apply_rec_subst_to_type(TypeBindings, Type0, Type),
-    output_type(Type, TypeVarSet, HeadTypeParams, !IO).
+    Pieces = type_to_pieces(Type, TypeVarSet, HeadTypeParams).
 
-:- pred write_arg_type_stuff_list(prog_context::in, list(arg_type_stuff)::in,
-    io::di, io::uo) is det.
+:- func arg_type_stuff_list_to_pieces(list(arg_type_stuff))
+    = list(format_component).
 
-write_arg_type_stuff_list(Context, TypeStuffs, !IO) :-
-    io.write_list(TypeStuffs, ",\n", write_arg_type_stuff(Context), !IO).
+arg_type_stuff_list_to_pieces(TypeStuffs) =
+    component_list_to_line_pieces(
+        list.map(arg_type_stuff_to_pieces, TypeStuffs), []).
 
-:- pred write_arg_type_stuff(prog_context::in, arg_type_stuff::in,
-    io::di, io::uo) is det.
+:- func arg_type_stuff_to_pieces(arg_type_stuff) = list(format_component).
 
-write_arg_type_stuff(Context, ArgTypeStuff, !IO) :-
+arg_type_stuff_to_pieces(ArgTypeStuff) = Pieces :-
     ArgTypeStuff = arg_type_stuff(Type, VarType, TVarSet, HeadTypeParams),
-    prog_out.write_context(Context, !IO),
-    io.write_string("    (inferred) ", !IO),
-    output_type(VarType, TVarSet, HeadTypeParams, !IO),
-    io.write_string(",\n", !IO),
-    prog_out.write_context(Context, !IO),
-    io.write_string("    (expected) ", !IO),
-    output_type(Type, TVarSet, HeadTypeParams, !IO).
+    Pieces = [words("(inferred)")] ++
+        type_to_pieces(VarType, TVarSet, HeadTypeParams) ++
+        [suffix(","), nl, words("(expected)")] ++
+        type_to_pieces(Type, TVarSet, HeadTypeParams).
 
 %-----------------------------------------------------------------------------%
 
-:- pred maybe_report_missing_import(typecheck_info::in, module_specifier::in,
-    io::di, io::uo) is det.
+:- func maybe_report_missing_import_addendum(typecheck_info, module_specifier)
+    = list(format_component).
 
-maybe_report_missing_import(Info, ModuleQualifier, !IO) :-
-    typecheck_info_get_context(Info, Context),
-    %
+maybe_report_missing_import_addendum(Info, ModuleQualifier) = Pieces :-
     % First check if this module wasn't imported.
-    %
     typecheck_info_get_module_info(Info, ModuleInfo),
     (
-        % If the module qualifier couldn't match any of the visible
-        % modules, then we report that the module has not been
-        % imported.
+        % If the module qualifier couldn't match any of the visible modules,
+        % then we report that the module has not been imported.
         \+ (
             visible_module(VisibleModule, ModuleInfo),
             match_sym_name(ModuleQualifier, VisibleModule)
         )
     ->
-        io.write_string("\n", !IO),
-        error_util.write_error_pieces(Context, 2,
-            [words("(the module "),
-            fixed(error_util.describe_sym_name(ModuleQualifier)),
-            words("has not been imported).")], !IO)
-    ;
-        % The module qualifier matches one or more of the
-        % visible modules.  But maybe the user forgot to
-        % import the parent module(s) of that module...
+        Pieces = [nl, words("(the module"), sym_name(ModuleQualifier),
+            words("has not been imported)."), nl]
+    ;
+        % The module qualifier matches one or more of the visible modules.
+        % But maybe the user forgot to import the parent module(s) of that
+        % module...
         solutions.solutions(get_unimported_parent(ModuleQualifier,
             ModuleInfo), UnimportedParents),
-        UnimportedParents \= []
+        UnimportedParents = [_ | _]
     ->
-        io.write_string("\n", !IO),
-        report_unimported_parents(Context, UnimportedParents, !IO)
+        Pieces = [nl | report_unimported_parents(UnimportedParents)]
     ;
-        io.write_string(".\n", !IO)
+        Pieces = [suffix("."), nl]
     ).
 
     % Nondeterministically return all the possible parent modules which could
@@ -1674,79 +1601,93 @@
     list.member(UnimportedParent, ParentModules),
     \+ visible_module(UnimportedParent, ModuleInfo).
 
-:- pred report_unimported_parents(prog_context::in, list(module_name)::in,
-    io::di, io::uo) is det.
+:- func report_unimported_parents(list(module_name)) = list(format_component).
 
-report_unimported_parents(Context, UnimportedParents, !IO) :-
+report_unimported_parents(UnimportedParents) = Pieces :-
     UnimportedParentDescs = list.map(describe_sym_name, UnimportedParents),
     AllUnimportedParents = list_to_pieces(UnimportedParentDescs),
-    error_util.write_error_pieces(Context, 2,
         ( AllUnimportedParents = [_] ->
-            [words("(the possible parent module ")]
-            ++ AllUnimportedParents
-            ++ [words("has not been imported).")]
-        ;
-            [words("(the possible parent modules ")]
-            ++ AllUnimportedParents
-            ++ [words("have not been imported).")]
-        ), !IO).
+        Pieces = [words("(the possible parent module")]
+            ++ AllUnimportedParents ++ [words("has not been imported).")]
+    ;
+        Pieces = [words("(the possible parent modules")]
+            ++ AllUnimportedParents ++ [words("have not been imported).")]
+    ).
 
 %-----------------------------------------------------------------------------%
 
-:- pred write_call_context(prog_context::in, pred_markers::in,
-    call_id::in, int::in, unify_context::in, io::di, io::uo) is det.
+:- func call_context_to_pieces(pred_markers, call_id, int, unify_context)
+    = list(format_component).
 
-write_call_context(Context, PredMarkers, CallId, ArgNum, UnifyContext) -->
-    ( { ArgNum = 0 } ->
-        hlds_out.write_unify_context(UnifyContext, Context)
-    ;
-        prog_out.write_context(Context),
-        io.write_string("  in "),
-        hlds_out.write_call_arg_id(CallId, ArgNum, PredMarkers),
-        io.write_string(":\n")
+call_context_to_pieces(PredMarkers, CallId, ArgNum, UnifyContext) = Pieces :-
+    ( ArgNum = 0 ->
+        unify_context_to_pieces(UnifyContext, [], Pieces)
+    ;
+        Pieces = [words("in"),
+            words(call_arg_id_to_string(CallId, ArgNum, PredMarkers)),
+            suffix(":"), nl]
     ).
 
-:- pred write_typecheck_info_context(typecheck_info::in, io::di, io::uo)
-    is det.
-
-write_typecheck_info_context(Info, !IO) :-
-    write_context_and_pred_id(Info, !IO),
-    typecheck_info_get_context(Info, Context),
-    prog_out.write_context(Context, !IO).
-
-:- pred write_context_and_pred_id(typecheck_info::in, io::di, io::uo) is det.
+    % This function generates the preamble (initial part of) all type error
+    % messages, giving the name of the predicate or function in which the error
+    % occurred.
+    %
+:- func in_clause_for_pieces(typecheck_info) = list(format_component).
 
-write_context_and_pred_id(Info, !IO) :-
+in_clause_for_pieces(Info) = Pieces :-
     typecheck_info_get_module_info(Info, ModuleInfo),
-    typecheck_info_get_context(Info, Context),
     typecheck_info_get_predid(Info, PredId),
-    prog_out.write_context(Context, !IO),
-    io.write_string("In clause for ", !IO),
-    hlds_out.write_pred_id(ModuleInfo, PredId, !IO),
-    io.write_string(":\n", !IO).
-
-    % This is intended to supercede the above predicate - It performs the
-    % same action, but instead of just writing to the output straight away
-    % the resultant string is passed back to the caller to deal with.
-    % This allows `nicer' handling of error messages, since this string
-    % can be used by the predicates in error_util.m
+    PredIdPieces = describe_one_pred_name(ModuleInfo,
+        should_not_module_qualify, PredId),
+    Pieces = [words("In clause for") | PredIdPieces] ++ [suffix(":"), nl].
+
+    % error_num_args_to_pieces(MaybePredOrFunc, Arity, CorrectArities):
     %
-    % The string generated by this predicate is of the form:
-    % In clause for module.pred/N:
+    % Return a description for the error message
+    % "wrong number of arguments (<Arity>; should be <CorrectArities>)",
+    % adjusting `Arity' and `CorrectArities' if `MaybePredOrFunc' is
+    % `yes(function)'.
     %
-:- pred make_pred_id_preamble(typecheck_info::in, string::out) is det.
+:- func error_num_args_to_pieces(maybe(pred_or_func), int, list(int)) =
+    list(format_component).
 
-make_pred_id_preamble(Info, Preamble) :-
-    typecheck_info_get_module_info(Info, Module),
-    typecheck_info_get_predid(Info, PredId),
-    PredPieces = describe_one_pred_name(Module, should_not_module_qualify,
-        PredId),
-    PredName = error_pieces_to_string(PredPieces),
-    Preamble = "In clause for " ++ PredName ++ ":".
-
-    % Check whether two types are identical ignoring their
-    % prog_contexts, i.e. whether they can be unified without
-    % binding any type parameters.
+error_num_args_to_pieces(MaybePredOrFunc, Arity0, Arities0) = Pieces :-
+    % Adjust arities for functions.
+    ( MaybePredOrFunc = yes(function) ->
+        adjust_func_arity(function, Arity, Arity0),
+        ReverseAdjust =
+            ( pred(OtherArity0::in, OtherArity::out) is det :-
+                adjust_func_arity(function, OtherArity, OtherArity0)
+            ),
+        list.map(ReverseAdjust, Arities0, Arities)
+    ;
+        Arity = Arity0,
+        Arities = Arities0
+    ),
+    RightAritiesPieces = error_right_num_args_to_pieces(Arities),
+    Pieces = [words("wrong number of arguments ("),
+        suffix(int_to_string(Arity)), suffix(";"),
+        words("should be") | RightAritiesPieces] ++ [suffix(")")].
+
+:- func error_right_num_args_to_pieces(list(int)) = list(format_component).
+
+error_right_num_args_to_pieces([]) = [].
+error_right_num_args_to_pieces([Arity | Arities]) = Pieces :-
+    TailPieces = error_right_num_args_to_pieces(Arities),
+    ArityPiece = fixed(int_to_string(Arity)),
+    (
+        Arities = [],
+        Pieces = [ArityPiece | TailPieces]
+    ;
+        Arities = [_],
+        Pieces = [ArityPiece, words("or") | TailPieces]
+    ;
+        Arities = [_, _ | _],
+        Pieces = [ArityPiece, suffix(",") | TailPieces]
+    ).
+
+    % Check whether two types are identical, i.e. whether they can be unified
+    % without binding any type parameters.
     %
 :- pred identical_types(mer_type::in, mer_type::in) is semidet.
 
@@ -1875,98 +1816,6 @@
 
 %-----------------------------------------------------------------------------%
 
-write_inference_messages([], _, !IO).
-write_inference_messages([PredId | PredIds], ModuleInfo, !IO) :-
-    module_info_pred_info(ModuleInfo, PredId, PredInfo),
-    pred_info_get_markers(PredInfo, Markers),
-    (
-        check_marker(Markers, marker_infer_type),
-        module_info_predids(ModuleInfo, ValidPredIds),
-        list.member(PredId, ValidPredIds),
-        \+ pred_info_get_goal_type(PredInfo, goal_type_promise(_))
-    ->
-        write_inference_message(PredInfo, !IO)
-    ;
-        true
-    ),
-    write_inference_messages(PredIds, ModuleInfo, !IO).
-
-    % Write out the inferred `pred' or `func' declaration
-    % for a single predicate.
-    %
-:- pred write_inference_message(pred_info::in, io::di, io::uo) is det.
-
-write_inference_message(PredInfo, !IO) :-
-    PredName = pred_info_name(PredInfo),
-    PredOrFunc = pred_info_is_pred_or_func(PredInfo),
-    Name = unqualified(PredName),
-    pred_info_context(PredInfo, Context),
-    pred_info_get_arg_types(PredInfo, VarSet, ExistQVars, Types0),
-    strip_builtin_qualifiers_from_type_list(Types0, Types),
-    pred_info_get_class_context(PredInfo, ClassContext),
-    pred_info_get_purity(PredInfo, Purity),
-    MaybeDet = no,
-    prog_out.write_context(Context, !IO),
-    io.write_string("Inferred ", !IO),
-    AppendVarNums = no,
-    (
-        PredOrFunc = predicate,
-        mercury_output_pred_type(VarSet, ExistQVars, Name, Types,
-            MaybeDet, Purity, ClassContext, Context, AppendVarNums, !IO)
-    ;
-        PredOrFunc = function,
-        pred_args_to_func_args(Types, ArgTypes, RetType),
-        mercury_output_func_type(VarSet, ExistQVars, Name, ArgTypes, RetType,
-            MaybeDet, Purity, ClassContext, Context, AppendVarNums, !IO)
-    ).
-
-checkpoint(Msg, !Info, !IO) :-
-    typecheck_info_get_module_info(!.Info, ModuleInfo),
-    module_info_get_globals(ModuleInfo, Globals),
-    globals.lookup_bool_option(Globals, debug_types, DoCheckPoint),
-    (
-        DoCheckPoint = yes,
-        checkpoint_2(Msg, !.Info, !IO)
-    ;
-        DoCheckPoint = no
-    ).
-
-:- pred checkpoint_2(string::in, typecheck_info::in, io::di, io::uo) is det.
-
-checkpoint_2(Msg, T0, !IO) :-
-    io.write_string("At ", !IO),
-    io.write_string(Msg, !IO),
-    io.write_string(": ", !IO),
-    globals.io_lookup_bool_option(detailed_statistics, Statistics, !IO),
-    maybe_report_stats(Statistics, !IO),
-    io.write_string("\n", !IO),
-    typecheck_info_get_type_assign_set(T0, TypeAssignSet),
-    (
-        Statistics = yes,
-        TypeAssignSet = [TypeAssign | _]
-    ->
-        type_assign_get_var_types(TypeAssign, VarTypes),
-        checkpoint_tree_stats("\t`var -> type' map", VarTypes, !IO),
-        type_assign_get_type_bindings(TypeAssign, TypeBindings),
-        checkpoint_tree_stats("\t`type var -> type' map", TypeBindings, !IO)
-    ;
-        true
-    ),
-    typecheck_info_get_varset(T0, VarSet),
-    write_type_assign_set(TypeAssignSet, VarSet, !IO).
-
-:- pred checkpoint_tree_stats(string::in, map(_K, _V)::in, io::di, io::uo)
-    is det.
-
-checkpoint_tree_stats(Description, Tree, !IO) :-
-    map.count(Tree, Count),
-    io.write_string(Description, !IO),
-    io.write_string(": count = ", !IO),
-    io.write_int(Count, !IO),
-    io.write_string("\n", !IO).
-
-%-----------------------------------------------------------------------------%
-
 :- func this_file = string.
 
 this_file = "typecheck_errors.m".
Index: compiler/typecheck_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck_info.m,v
retrieving revision 1.14
diff -u -b -r1.14 typecheck_info.m
--- compiler/typecheck_info.m	22 Aug 2006 05:04:12 -0000	1.14
+++ compiler/typecheck_info.m	6 Sep 2006 04:16:27 -0000
@@ -23,11 +23,13 @@
 :- import_module hlds.hlds_pred.
 :- import_module hlds.pred_table.
 :- import_module mdbcomp.prim_data.
+:- import_module parse_tree.error_util.
 :- import_module parse_tree.prog_data.
 
 :- import_module bool.
 :- import_module io.
 :- import_module list.
+:- import_module maybe.
 :- import_module map.
 
 %-----------------------------------------------------------------------------%
@@ -201,7 +203,6 @@
     prog_context::in, typecheck_info::in, typecheck_info::out) is det.
 
 %-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
 %
 % The type_assign and type_assign_set data structures.
 %
@@ -227,9 +228,6 @@
                                     % actual constraints.
             ).
 
-:- pred write_type_assign_set(type_assign_set::in, prog_varset::in,
-    io::di, io::uo) is det.
-
 %-----------------------------------------------------------------------------%
 %
 % Access predicates for type_assign.
@@ -266,7 +264,6 @@
     type_assign::in, type_assign::out) is det.
 
 %-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
 
 :- type args_type_assign_set == list(args_type_assign).
 
@@ -284,17 +281,15 @@
 :- func get_callee_arg_types(args_type_assign) = list(mer_type).
 :- func get_callee_constraints(args_type_assign) = hlds_constraints.
 
-:- pred write_args_type_assign_set(args_type_assign_set::in, prog_varset::in,
-    io::di, io::uo) is det.
-
-:- pred convert_nonempty_args_type_assign_set(args_type_assign_set::in,
-    type_assign_set::out) is det.
+    % XXX document me
+    %
+:- func convert_args_type_assign_set(args_type_assign_set) = type_assign_set.
 
-    % Same as convert_nonempty_args_type_assign_set, but does not abort
-    % when the args are empty.
+    % Same as convert_args_type_assign_set, but aborts when the args are
+    % non-empty.
     %
-:- pred convert_args_type_assign_set(args_type_assign_set::in,
-    type_assign_set::out) is det.
+:- func convert_args_type_assign_set_check_empty_args(args_type_assign_set) =
+    type_assign_set.
 
 %-----------------------------------------------------------------------------%
 
@@ -332,19 +327,44 @@
 :- func project_cons_type_info_source(cons_type_info) = cons_type_info_source.
 
 %-----------------------------------------------------------------------------%
+
+:- pred write_type_assign_set(type_assign_set::in, prog_varset::in,
+    io::di, io::uo) is det.
+
+:- func type_assign_set_to_pieces(type_assign_set, maybe(int), prog_varset)
+    = list(format_component).
+
+:- pred write_args_type_assign_set(args_type_assign_set::in, prog_varset::in,
+    io::di, io::uo) is det.
+
+:- func args_type_assign_set_to_pieces(args_type_assign_set, maybe(int),
+    prog_varset) = list(format_component).
+
+%-----------------------------------------------------------------------------%
+
+    % Used for debugging typechecking.
+    %
+:- pred type_checkpoint(string::in, typecheck_info::in, io::di, io::uo) is det.
+
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
 :- implementation.
 
 :- import_module check_hlds.type_util.
 :- import_module libs.compiler_util.
+:- import_module libs.globals.
+:- import_module libs.options.
 :- import_module parse_tree.mercury_to_mercury.
+:- import_module parse_tree.prog_out.
 :- import_module parse_tree.prog_type.
 :- import_module parse_tree.prog_type_subst.
 :- import_module parse_tree.prog_util.
 
+:- import_module int.
 :- import_module pair.
 :- import_module set.
+:- import_module string.
 :- import_module svmap.
 :- import_module term.
 :- import_module varset.
@@ -588,7 +608,6 @@
     typecheck_info_set_overloaded_symbols(SymbolMap, !Info).
 
 %-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
 
 type_assign_get_var_types(TA, TA ^ var_types).
 type_assign_get_typevarset(TA, TA ^ type_varset).
@@ -608,10 +627,54 @@
 
 %-----------------------------------------------------------------------------%
 
+convert_args_type_assign_set([]) = [].
+convert_args_type_assign_set([ArgsTypeAssign | ArgsTypeAssigns]) =
+    [convert_args_type_assign(ArgsTypeAssign) |
+    convert_args_type_assign_set(ArgsTypeAssigns)].
+
+convert_args_type_assign_set_check_empty_args([]) = [].
+convert_args_type_assign_set_check_empty_args([ArgTypeAssign | ArgTypeAssigns])
+        = Result :-
+    ArgTypeAssign = args(_, Args, _),
+    (
+        Args = [],
+        Result =
+            [convert_args_type_assign(ArgTypeAssign) |
+            convert_args_type_assign_set_check_empty_args(ArgTypeAssigns)]
+    ;
+        Args = [_ | _],
+        % This should never happen, since the arguments should all have been
+        % processed at this point.
+        unexpected(this_file, "convert_nonempty_args_type_assign_set")
+    ).
+
+:- func convert_args_type_assign(args_type_assign) = type_assign.
+
+convert_args_type_assign(args(TypeAssign0, _, Constraints0)) = TypeAssign :-
+    type_assign_get_typeclass_constraints(TypeAssign0, OldConstraints),
+    type_assign_get_type_bindings(TypeAssign0, Bindings),
+    apply_rec_subst_to_constraints(Bindings, Constraints0, Constraints),
+    merge_hlds_constraints(Constraints, OldConstraints, NewConstraints),
+    type_assign_set_typeclass_constraints(NewConstraints,
+        TypeAssign0, TypeAssign).
+
+get_caller_arg_assign(ArgsTypeAssign) = ArgsTypeAssign ^ caller_arg_assign.
+get_callee_arg_types(ArgsTypeAssign) = ArgsTypeAssign ^ callee_arg_types.
+get_callee_constraints(ArgsTypeAssign) = ArgsTypeAssign ^ callee_constraints.
+
+project_cons_type_info_source(CTI) = CTI ^ cti_source.
+
+%-----------------------------------------------------------------------------%
+
 :- func varnums = bool.
 
 varnums = yes.
 
+:- func inc_maybe_seq(maybe(int)) = maybe(int).
+
+inc_maybe_seq(no) = no.
+inc_maybe_seq(yes(N)) = yes(N + 1).
+
 write_type_assign_set([], _, !IO).
 write_type_assign_set([TypeAssign | TypeAssigns], VarSet, !IO) :-
     io.write_string("\t", !IO),
@@ -619,6 +682,31 @@
     io.write_string("\n", !IO),
     write_type_assign_set(TypeAssigns, VarSet, !IO).
 
+type_assign_set_to_pieces([], _, _) = [].
+type_assign_set_to_pieces([TypeAssign | TypeAssigns], MaybeSeq, VarSet) =
+    type_assign_to_pieces(TypeAssign, MaybeSeq, VarSet) ++
+    type_assign_set_to_pieces(TypeAssigns, inc_maybe_seq(MaybeSeq), VarSet).
+
+write_args_type_assign_set([], _, !IO).
+write_args_type_assign_set([ArgTypeAssign | ArgTypeAssigns], VarSet, !IO) :-
+    % XXX Why does this simply pick the TypeAssign part of the ArgTypeAssign,
+    % instead of invoking convert_args_type_assign?
+    ArgTypeAssign = args(TypeAssign, _ArgTypes, _Cnstrs),
+    io.write_string("\t", !IO),
+    write_type_assign(TypeAssign, VarSet, !IO),
+    io.write_string("\n", !IO),
+    write_args_type_assign_set(ArgTypeAssigns, VarSet, !IO).
+
+args_type_assign_set_to_pieces([], _, _) = [].
+args_type_assign_set_to_pieces([ArgTypeAssign | ArgTypeAssigns], MaybeSeq,
+        VarSet) = Pieces :-
+    % XXX Why does this simply pick the TypeAssign part of the ArgTypeAssign,
+    % instead of invoking convert_args_type_assign?
+    ArgTypeAssign = args(TypeAssign, _ArgTypes, _Cnstrs),
+    Pieces = type_assign_to_pieces(TypeAssign, MaybeSeq, VarSet) ++
+        args_type_assign_set_to_pieces(ArgTypeAssigns, inc_maybe_seq(MaybeSeq),
+            VarSet).
+
 :- pred write_type_assign(type_assign::in, prog_varset::in, io::di, io::uo)
     is det.
 
@@ -639,12 +727,48 @@
     ),
     write_type_assign_types(Vars, VarSet, VarTypes, TypeBindings, TypeVarSet,
         no, !IO),
-    write_type_assign_constraints(Constraints, TypeBindings, TypeVarSet, !IO),
+    write_type_assign_hlds_constraints(Constraints, TypeBindings, TypeVarSet,
+        !IO),
     io.write_string("\n", !IO).
 
+:- func type_assign_to_pieces(type_assign, maybe(int), prog_varset)
+    = list(format_component).
+
+type_assign_to_pieces(TypeAssign, MaybeSeq, VarSet) = Pieces :-
+    (
+        MaybeSeq = yes(N),
+        SeqPieces0 = [words("Type assignment"), int_fixed(N), suffix(":"), nl],
+        ( N > 1 ->
+            SeqPieces = [blank_line | SeqPieces0]
+        ;
+            SeqPieces = SeqPieces0
+        )
+    ;
+        MaybeSeq = no,
+        SeqPieces = []
+    ),
+    type_assign_get_head_type_params(TypeAssign, HeadTypeParams),
+    type_assign_get_var_types(TypeAssign, VarTypes),
+    type_assign_get_typeclass_constraints(TypeAssign, Constraints),
+    type_assign_get_type_bindings(TypeAssign, TypeBindings),
+    type_assign_get_typevarset(TypeAssign, TypeVarSet),
+    map.keys(VarTypes, Vars),
+    (
+        HeadTypeParams = [],
+        HeadPieces = []
+    ;
+        HeadTypeParams = [_ | _],
+        VarsStr = mercury_vars_to_string(HeadTypeParams, TypeVarSet, varnums),
+        HeadPieces = [words("some [" ++ VarsStr ++ "]"), nl]
+    ),
+    TypePieces = type_assign_types_to_pieces(Vars, VarSet, VarTypes,
+        TypeBindings, TypeVarSet, no),
+    ConstraintPieces = type_assign_hlds_constraints_to_pieces(Constraints,
+        TypeBindings, TypeVarSet),
+    Pieces = SeqPieces ++ HeadPieces ++ TypePieces ++ ConstraintPieces ++ [nl].
+
 :- pred write_type_assign_types(list(prog_var)::in, prog_varset::in,
-    vartypes::in, tsubst::in, tvarset::in, bool::in,
-    io::di, io::uo) is det.
+    vartypes::in, tsubst::in, tvarset::in, bool::in, io::di, io::uo) is det.
 
 write_type_assign_types([], _, _, _, _, FoundOne, !IO) :-
     (
@@ -672,16 +796,62 @@
             TypeVarSet, FoundOne, !IO)
     ).
 
-:- pred write_type_assign_constraints(hlds_constraints::in,
+:- func type_assign_types_to_pieces(list(prog_var), prog_varset,
+    vartypes, tsubst, tvarset, bool) = list(format_component).
+
+type_assign_types_to_pieces([], _, _, _, _, FoundOne) = Pieces :-
+    (
+        FoundOne = no,
+        Pieces = [words("(No variables were assigned a type)")]
+    ;
+        FoundOne = yes,
+        Pieces = []
+    ).
+type_assign_types_to_pieces([Var | Vars], VarSet, VarTypes, TypeBindings,
+        TypeVarSet, FoundOne) = Pieces :-
+    ( map.search(VarTypes, Var, Type) ->
+        (
+            FoundOne = yes,
+            PrefixPieces = [nl]
+        ;
+            FoundOne = no,
+            PrefixPieces = []
+        ),
+        VarStr = mercury_var_to_string(Var, VarSet, varnums),
+        TypeStr = type_with_bindings_to_string(Type, TypeVarSet, TypeBindings),
+        AssignPieces = [fixed(VarStr), suffix(":"), words(TypeStr)],
+        TailPieces = type_assign_types_to_pieces(Vars, VarSet, VarTypes,
+            TypeBindings, TypeVarSet, yes),
+        Pieces = PrefixPieces ++ AssignPieces ++ TailPieces
+    ;
+        Pieces = type_assign_types_to_pieces(Vars, VarSet, VarTypes,
+            TypeBindings, TypeVarSet, FoundOne)
+    ).
+
+:- pred write_type_assign_hlds_constraints(hlds_constraints::in,
     tsubst::in, tvarset::in, io::di, io::uo) is det.
 
-write_type_assign_constraints(Constraints, TypeBindings, TypeVarSet, !IO) :-
+write_type_assign_hlds_constraints(Constraints, TypeBindings, TypeVarSet,
+        !IO) :-
     Constraints = constraints(ConstraintsToProve, AssumedConstraints, _),
     write_type_assign_constraints("&", AssumedConstraints,
         TypeBindings, TypeVarSet, no, !IO),
     write_type_assign_constraints("<=", ConstraintsToProve,
         TypeBindings, TypeVarSet, no, !IO).
 
+:- func type_assign_hlds_constraints_to_pieces(hlds_constraints,
+    tsubst, tvarset) = list(format_component).
+
+type_assign_hlds_constraints_to_pieces(Constraints, TypeBindings, TypeVarSet)
+        = Pieces1 ++ Pieces2 :-
+    Constraints = constraints(ConstraintsToProve, AssumedConstraints, _),
+    PiecesList1 = type_assign_constraints_to_pieces_list("&",
+        AssumedConstraints, TypeBindings, TypeVarSet, no),
+    PiecesList2 = type_assign_constraints_to_pieces_list("<=",
+        ConstraintsToProve, TypeBindings, TypeVarSet, no),
+    Pieces1 = component_list_to_line_pieces(PiecesList1, []),
+    Pieces2 = component_list_to_line_pieces(PiecesList2, []).
+
 :- pred write_type_assign_constraints(string::in, list(hlds_constraint)::in,
     tsubst::in, tvarset::in, bool::in, io::di, io::uo) is det.
 
@@ -701,6 +871,26 @@
     write_type_assign_constraints(Operator, Constraints, TypeBindings,
         TypeVarSet, yes, !IO).
 
+:- func type_assign_constraints_to_pieces_list(string, list(hlds_constraint),
+    tsubst, tvarset, bool) = list(list(format_component)).
+
+type_assign_constraints_to_pieces_list(_, [], _, _, _) = [].
+type_assign_constraints_to_pieces_list(Operator, [Constraint | Constraints],
+        TypeBindings, TypeVarSet, FoundOne) = [ThisPieces] ++ TailPieceLists :-
+    (
+        FoundOne = no,
+        Prefix = Operator ++ " "
+    ;
+        FoundOne = yes,
+        Prefix = "   "
+    ),
+    apply_rec_subst_to_constraint(TypeBindings, Constraint, BoundConstraint),
+    retrieve_prog_constraint(BoundConstraint, ProgConstraint),
+    ThisPieces = [fixed(Prefix ++
+        mercury_constraint_to_string(TypeVarSet, ProgConstraint))],
+    TailPieceLists = type_assign_constraints_to_pieces_list(Operator,
+        Constraints, TypeBindings, TypeVarSet, yes).
+
     % write_type_with_bindings writes out a type after applying the
     % type bindings.
     %
@@ -712,53 +902,60 @@
     strip_builtin_qualifiers_from_type(Type1, Type),
     mercury_output_type(TypeVarSet, no, Type, !IO).
 
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
+:- func type_with_bindings_to_string(mer_type, tvarset, tsubst) = string.
 
-write_args_type_assign_set([], _, !IO).
-write_args_type_assign_set([ArgTypeAssign | ArgTypeAssigns], VarSet, !IO) :-
-    ArgTypeAssign = args(TypeAssign, _ArgTypes, _Cnstrs),
-    io.write_string("\t", !IO),
-    write_type_assign(TypeAssign, VarSet, !IO),
-    io.write_string("\n", !IO),
-    write_args_type_assign_set(ArgTypeAssigns, VarSet, !IO).
+type_with_bindings_to_string(Type0, TypeVarSet, TypeBindings) = Str :-
+    apply_rec_subst_to_type(TypeBindings, Type0, Type1),
+    strip_builtin_qualifiers_from_type(Type1, Type),
+    Str = mercury_type_to_string(TypeVarSet, no, Type).
 
-convert_nonempty_args_type_assign_set([], []).
-convert_nonempty_args_type_assign_set([ArgTypeAssign | ArgTypeAssigns],
-        [TypeAssign | TypeAssigns]) :-
-    ArgTypeAssign = args(_, Args, _),
+%-----------------------------------------------------------------------------%
+
+type_checkpoint(Msg, Info, !IO) :-
+    typecheck_info_get_module_info(Info, ModuleInfo),
+    module_info_get_globals(ModuleInfo, Globals),
+    globals.lookup_bool_option(Globals, debug_types, DoCheckPoint),
     (
-        Args = [],
-        convert_args_type_assign(ArgTypeAssign, TypeAssign)
+        DoCheckPoint = yes,
+        do_type_checkpoint(Msg, Info, !IO)
     ;
-        Args = [_ | _],
-        % this should never happen, since the arguments should
-        % all have been processed at this point
-        unexpected(this_file, "convert_nonempty_args_type_assign_set")
-    ),
-    convert_nonempty_args_type_assign_set(ArgTypeAssigns, TypeAssigns).
-
-convert_args_type_assign_set([], []).
-convert_args_type_assign_set([X | Xs], [Y | Ys]) :-
-    convert_args_type_assign(X, Y),
-    convert_args_type_assign_set(Xs, Ys).
+        DoCheckPoint = no
+    ).
 
-:- pred convert_args_type_assign(args_type_assign::in, type_assign::out)
+:- pred do_type_checkpoint(string::in, typecheck_info::in, io::di, io::uo)
     is det.
 
-convert_args_type_assign(args(TypeAssign0, _, Constraints0), TypeAssign) :-
-    type_assign_get_typeclass_constraints(TypeAssign0, OldConstraints),
-    type_assign_get_type_bindings(TypeAssign0, Bindings),
-    apply_rec_subst_to_constraints(Bindings, Constraints0, Constraints),
-    merge_hlds_constraints(Constraints, OldConstraints, NewConstraints),
-    type_assign_set_typeclass_constraints(NewConstraints,
-        TypeAssign0, TypeAssign).
+do_type_checkpoint(Msg, T0, !IO) :-
+    io.write_string("At ", !IO),
+    io.write_string(Msg, !IO),
+    io.write_string(": ", !IO),
+    globals.io_lookup_bool_option(detailed_statistics, Statistics, !IO),
+    maybe_report_stats(Statistics, !IO),
+    io.write_string("\n", !IO),
+    typecheck_info_get_type_assign_set(T0, TypeAssignSet),
+    (
+        Statistics = yes,
+        TypeAssignSet = [TypeAssign | _]
+    ->
+        type_assign_get_var_types(TypeAssign, VarTypes),
+        checkpoint_tree_stats("\t`var -> type' map", VarTypes, !IO),
+        type_assign_get_type_bindings(TypeAssign, TypeBindings),
+        checkpoint_tree_stats("\t`type var -> type' map", TypeBindings, !IO)
+    ;
+        true
+    ),
+    typecheck_info_get_varset(T0, VarSet),
+    write_type_assign_set(TypeAssignSet, VarSet, !IO).
 
-get_caller_arg_assign(ArgsTypeAssign) = ArgsTypeAssign ^ caller_arg_assign.
-get_callee_arg_types(ArgsTypeAssign) = ArgsTypeAssign ^ callee_arg_types.
-get_callee_constraints(ArgsTypeAssign) = ArgsTypeAssign ^ callee_constraints.
+:- pred checkpoint_tree_stats(string::in, map(_K, _V)::in, io::di, io::uo)
+    is det.
 
-project_cons_type_info_source(CTI) = CTI ^ cti_source.
+checkpoint_tree_stats(Description, Tree, !IO) :-
+    map.count(Tree, Count),
+    io.write_string(Description, !IO),
+    io.write_string(": count = ", !IO),
+    io.write_int(Count, !IO),
+    io.write_string("\n", !IO).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/typeclasses.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typeclasses.m,v
retrieving revision 1.12
diff -u -b -r1.12 typeclasses.m
--- compiler/typeclasses.m	31 Jul 2006 08:32:09 -0000	1.12
+++ compiler/typeclasses.m	2 Sep 2006 10:09:12 -0000
@@ -107,7 +107,7 @@
 %-----------------------------------------------------------------------------%
 
 perform_context_reduction(OrigTypeAssignSet, !Info, !IO) :-
-    checkpoint("before context reduction", !Info, !IO),
+    type_checkpoint("before context reduction", !.Info, !IO),
     typecheck_info_get_module_info(!.Info, ModuleInfo),
     module_info_get_class_table(ModuleInfo, ClassTable),
     module_info_get_superclass_table(ModuleInfo, SuperClassTable),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/list.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/list.m,v
retrieving revision 1.152
diff -u -b -r1.152 list.m
--- library/list.m	8 Aug 2006 05:26:38 -0000	1.152
+++ library/list.m	31 Aug 2006 10:14:25 -0000
@@ -1199,6 +1199,16 @@
 
 :- interface.
 
+    % This is the same as the usual forward mode of append, but preserves
+    % any extra information available in the input arguments.
+    % NOTE: If Mercury recorded the mode and determinism information
+    % of higher order types in the *types* of higher order variables
+    % instead of in their *insts*, this function would not be needed.
+    %
+:- func inst_preserving_append(list(T)::in(list_skel(I =< ground)),
+    list(T)::in(list_skel(I =< ground))) =
+    (list(T)::out(list_skel(I =< ground))) is det.
+
 :- import_module term.      % for var/1.
 
 :- pragma type_spec(list.merge(in, in, out), T = var(_)).
@@ -2315,4 +2325,10 @@
     ).
 
 %-----------------------------------------------------------------------------%
+
+inst_preserving_append([], L) = L.
+inst_preserving_append([H | T], L) = [H | NT] :-
+    inst_preserving_append(T, L) = NT.
+
+%-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
Index: tests/hard_coded/allow_stubs.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/allow_stubs.exp,v
retrieving revision 1.1
diff -u -b -r1.1 allow_stubs.exp
--- tests/hard_coded/allow_stubs.exp	21 Feb 2003 01:57:31 -0000	1.1
+++ tests/hard_coded/allow_stubs.exp	5 Sep 2006 16:28:36 -0000
@@ -1,4 +1,4 @@
 hello world
-[caught exception: software_error("no clauses for predicate `allow_stubs.how_are_you/2\'")]
-going [caught exception: software_error("no clauses for predicate `allow_stubs.today/2\'")]
+[caught exception: software_error("no clauses for predicate `allow_stubs.how_are_you\'/2")]
+going [caught exception: software_error("no clauses for predicate `allow_stubs.today\'/2")]
 goodbye
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
Index: tests/invalid/ambiguous_method.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ambiguous_method.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 ambiguous_method.err_exp
--- tests/invalid/ambiguous_method.err_exp	14 Jun 2006 08:14:51 -0000	1.3
+++ tests/invalid/ambiguous_method.err_exp	5 Sep 2006 12:07:00 -0000
@@ -1,4 +1,4 @@
-ambiguous_method.m:018: In declaration for function `ambiguous_method.e/0':
+ambiguous_method.m:018: In declaration for function `ambiguous_method.e'/0:
 ambiguous_method.m:018:   error in type class constraints: type variable E
 ambiguous_method.m:018:   occurs in the constraints, but is not determined by
 ambiguous_method.m:018:   the function's argument or result types.
Index: tests/invalid/ambiguous_method_2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ambiguous_method_2.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 ambiguous_method_2.err_exp
--- tests/invalid/ambiguous_method_2.err_exp	14 Jun 2006 08:14:51 -0000	1.3
+++ tests/invalid/ambiguous_method_2.err_exp	5 Sep 2006 12:07:01 -0000
@@ -1,4 +1,4 @@
-ambiguous_method_2.m:028: In declaration for function `ambiguous_method_2.e/0':
+ambiguous_method_2.m:028: In declaration for function `ambiguous_method_2.e'/0:
 ambiguous_method_2.m:028:   error in type class constraints: type variable E
 ambiguous_method_2.m:028:   occurs in the constraints, but is not determined by
 ambiguous_method_2.m:028:   the function's argument or result types.
Index: tests/invalid/any_mode.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/any_mode.err_exp,v
retrieving revision 1.10
diff -u -b -r1.10 any_mode.err_exp
--- tests/invalid/any_mode.err_exp	14 Jun 2006 08:14:51 -0000	1.10
+++ tests/invalid/any_mode.err_exp	5 Sep 2006 12:07:01 -0000
@@ -1,7 +1,7 @@
 any_mode.m:001: Warning: interface for module `any_mode' does not export
 any_mode.m:001:   anything.
 any_mode.m:006: In clause for `p((any >> ground))':
-any_mode.m:006:   in argument 1 of call to predicate `any_mode.q/1':
+any_mode.m:006:   in argument 1 of call to predicate `any_mode.q'/1:
 any_mode.m:006:   mode error: variable `X' has instantiatedness `any',
 any_mode.m:006:   expected instantiatedness was `ground'.
 For more information, recompile with `-E'.
Index: tests/invalid/any_passed_as_ground.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/any_passed_as_ground.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 any_passed_as_ground.err_exp
--- tests/invalid/any_passed_as_ground.err_exp	14 Jun 2006 08:14:51 -0000	1.4
+++ tests/invalid/any_passed_as_ground.err_exp	6 Sep 2006 14:42:18 -0000
@@ -1,5 +1,5 @@
 any_passed_as_ground.m:036: In clause for `main(di, uo)':
-any_passed_as_ground.m:036:   in call to predicate `list.member/2':
+any_passed_as_ground.m:036:   in call to predicate `list.member'/2:
 any_passed_as_ground.m:036:   mode error: arguments `TypeInfo_16, V_11, Xs'
 any_passed_as_ground.m:036:   have the following insts:
 any_passed_as_ground.m:036:     unique(private_builtin.type_info(unique(<type_ctor_info
@@ -9,5 +9,5 @@
 any_passed_as_ground.m:036:     free,
 any_passed_as_ground.m:036:     any
 any_passed_as_ground.m:036:   which does not match any of the modes for
-any_passed_as_ground.m:036:   predicate `list.member/2'.
+any_passed_as_ground.m:036:   predicate `list.member'/2.
 For more information, recompile with `-E'.
Index: tests/invalid/any_should_not_match_bound.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/any_should_not_match_bound.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 any_should_not_match_bound.err_exp
--- tests/invalid/any_should_not_match_bound.err_exp	14 Jun 2006 08:14:51 -0000	1.5
+++ tests/invalid/any_should_not_match_bound.err_exp	5 Sep 2006 12:07:02 -0000
@@ -1,26 +1,25 @@
 any_should_not_match_bound.m:021: In clause for `test_any_poly(in(any), out)':
 any_should_not_match_bound.m:021:   in argument 1 of call to predicate
-any_should_not_match_bound.m:021:   `any_should_not_match_bound.p/2':
+any_should_not_match_bound.m:021:   `any_should_not_match_bound.p'/2:
 any_should_not_match_bound.m:021:   mode error: variable `X' has
 any_should_not_match_bound.m:021:   instantiatedness `any',
 any_should_not_match_bound.m:021:   expected instantiatedness was `ground'.
 any_should_not_match_bound.m:024: In clause for `test_any_tuple(in(any), out)':
 any_should_not_match_bound.m:024:   in argument 1 of call to predicate
-any_should_not_match_bound.m:024:   `any_should_not_match_bound.p/2':
+any_should_not_match_bound.m:024:   `any_should_not_match_bound.p'/2:
 any_should_not_match_bound.m:024:   mode error: variable `X' has
 any_should_not_match_bound.m:024:   instantiatedness `any',
 any_should_not_match_bound.m:024:   expected instantiatedness was `ground'.
 any_should_not_match_bound.m:027: In clause for `test_any_du(in(any), out)':
 any_should_not_match_bound.m:027:   in argument 1 of call to predicate
-any_should_not_match_bound.m:027:   `any_should_not_match_bound.p/2':
+any_should_not_match_bound.m:027:   `any_should_not_match_bound.p'/2:
 any_should_not_match_bound.m:027:   mode error: variable `X' has
 any_should_not_match_bound.m:027:   instantiatedness `any',
 any_should_not_match_bound.m:027:   expected instantiatedness was `ground'.
 any_should_not_match_bound.m:030: In clause for `test_any_solver(in(any),
 any_should_not_match_bound.m:030:   out)':
 any_should_not_match_bound.m:030:   in argument 1 of call to predicate
-any_should_not_match_bound.m:030:   `any_should_not_match_bound.p/2':
+any_should_not_match_bound.m:030:   `any_should_not_match_bound.p'/2:
 any_should_not_match_bound.m:030:   mode error: variable `X' has
 any_should_not_match_bound.m:030:   instantiatedness `any',
 any_should_not_match_bound.m:030:   expected instantiatedness was `ground'.
-For more information, recompile with `-E'.
Index: tests/invalid/any_to_ground_in_ite_cond.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/any_to_ground_in_ite_cond.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 any_to_ground_in_ite_cond.err_exp
--- tests/invalid/any_to_ground_in_ite_cond.err_exp	14 Jun 2006 08:14:52 -0000	1.4
+++ tests/invalid/any_to_ground_in_ite_cond.err_exp	5 Sep 2006 12:07:03 -0000
@@ -1,6 +1,6 @@
 any_to_ground_in_ite_cond.m:036: In clause for `main(di, uo)':
 any_to_ground_in_ite_cond.m:036:   in argument 1 of call to predicate
-any_to_ground_in_ite_cond.m:036:   `any_to_ground_in_ite_cond.p/1':
+any_to_ground_in_ite_cond.m:036:   `any_to_ground_in_ite_cond.p'/1:
 any_to_ground_in_ite_cond.m:036:   scope error: attempt to bind a non-local
 any_to_ground_in_ite_cond.m:036:   variable inside the condition of an
 any_to_ground_in_ite_cond.m:036:   if-then-else.
Index: tests/invalid/assert_in_interface.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/assert_in_interface.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 assert_in_interface.err_exp
--- tests/invalid/assert_in_interface.err_exp	14 Jun 2006 08:14:52 -0000	1.6
+++ tests/invalid/assert_in_interface.err_exp	5 Sep 2006 12:07:04 -0000
@@ -1,6 +1,6 @@
 assert_in_interface.m:005: In interface for module `assert_in_interface':
 assert_in_interface.m:005:   error: exported promise refers to predicate
-assert_in_interface.m:005:   `list.last/2' which is defined in the
+assert_in_interface.m:005:   `list.last'/2 which is defined in the
 assert_in_interface.m:005:   implementation section of module
 assert_in_interface.m:005:   `assert_in_interface'.
 assert_in_interface.m:005:   Either move the promise into the implementation
Index: tests/invalid/bigtest.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/bigtest.err_exp,v
retrieving revision 1.11
diff -u -b -r1.11 bigtest.err_exp
--- tests/invalid/bigtest.err_exp	14 Jun 2006 08:14:52 -0000	1.11
+++ tests/invalid/bigtest.err_exp	5 Sep 2006 12:07:08 -0000
@@ -12,10 +12,10 @@
 bigtest.m:001: Warning: declaration not yet implemented.
 bigtest.m:002: Warning: declaration not yet implemented.
 bigtest.m:003: Warning: declaration not yet implemented.
-bigtest.m:005: Error: clause for predicate `bigtest.fact/0'
+bigtest.m:005: Error: clause for predicate `bigtest.fact'/0
 bigtest.m:005:   without preceding `pred' declaration.
 bigtest.m:005: Inferred :- pred fact.
-bigtest.m:010: Error: no mode declaration for predicate `bigtest.p/1'.
+bigtest.m:010: Error: no mode declaration for predicate `p'/1.
 bigtest.m:010:   (Use `--infer-modes' to enable mode inference.)
-bigtest.m:005: Error: no mode declaration for predicate `bigtest.fact/0'.
+bigtest.m:005: Error: no mode declaration for predicate `fact'/0.
 bigtest.m:005:   (Use `--infer-modes' to enable mode inference.)
Index: tests/invalid/bind_var_errors.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/bind_var_errors.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 bind_var_errors.err_exp
--- tests/invalid/bind_var_errors.err_exp	27 Jul 2006 05:03:48 -0000	1.9
+++ tests/invalid/bind_var_errors.err_exp	5 Sep 2006 12:07:09 -0000
@@ -16,13 +16,13 @@
 bind_var_errors.m:048:   lambda goals is `ground'.
 bind_var_errors.m:053: In clause for `share_var_in_lambda(di)':
 bind_var_errors.m:053:   in argument 1 of call to predicate
-bind_var_errors.m:053:   `bind_var_errors.destroy/1':
+bind_var_errors.m:053:   `bind_var_errors.destroy'/1:
 bind_var_errors.m:053:   mode error: variable `X' has instantiatedness
 bind_var_errors.m:053:   `ground',
 bind_var_errors.m:053:   expected instantiatedness was `unique'.
 bind_var_errors.m:060: In clause for `clobber_var_in_lambda(di)':
 bind_var_errors.m:060:   in argument 1 of call to predicate
-bind_var_errors.m:060:   `bind_var_errors.destroy/1':
+bind_var_errors.m:060:   `bind_var_errors.destroy'/1:
 bind_var_errors.m:060:   unique-mode error: the called procedure would clobber
 bind_var_errors.m:060:   its argument, but variable `X' is still live.
 For more information, recompile with `-E'.
Index: tests/invalid/builtin_proc.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/builtin_proc.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 builtin_proc.err_exp
--- tests/invalid/builtin_proc.err_exp	14 Sep 2005 05:26:43 -0000	1.3
+++ tests/invalid/builtin_proc.err_exp	5 Sep 2006 12:07:10 -0000
@@ -1,2 +1,2 @@
-builtin_proc.m:013: In clause for predicate `builtin_proc.foo/2':
-builtin_proc.m:013:   error: undefined predicate `builtin.no_such_pred/2'.
+builtin_proc.m:013: In clause for predicate `foo'/2:
+builtin_proc.m:013:   error: undefined predicate `builtin.no_such_pred'/2.
Index: tests/invalid/circ_type.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/circ_type.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 circ_type.err_exp
--- tests/invalid/circ_type.err_exp	14 Sep 2005 05:26:43 -0000	1.4
+++ tests/invalid/circ_type.err_exp	2 Sep 2006 12:59:15 -0000
@@ -1,3 +1,3 @@
-circ_type.m:006: Error: circular equivalence type `circ_type.circ/0'.
-circ_type.m:008: Error: circular equivalence type `circ_type.circ1/0'.
-circ_type.m:010: Error: circular equivalence type `circ_type.circ2/0'.
+circ_type.m:006: Error: circular equivalence type `circ_type.circ'/0.
+circ_type.m:008: Error: circular equivalence type `circ_type.circ1'/0.
+circ_type.m:010: Error: circular equivalence type `circ_type.circ2'/0.
Index: tests/invalid/circ_type2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/circ_type2.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 circ_type2.err_exp
--- tests/invalid/circ_type2.err_exp	14 Sep 2005 05:26:43 -0000	1.3
+++ tests/invalid/circ_type2.err_exp	2 Sep 2006 12:59:15 -0000
@@ -1,8 +1,8 @@
-circ_type2.m:010: Error: circular equivalence type `circ_type2.circ1/1'.
-circ_type2.m:011: Error: circular equivalence type `circ_type2.circ2/1'.
-circ_type2.m:012: Error: circular equivalence type `circ_type2.circ3/1'.
-circ_type2.m:013: Error: circular equivalence type `circ_type2.circ4/1'.
-circ_type2.m:015: Error: circular equivalence type `circ_type2.left/1'.
-circ_type2.m:016: Error: circular equivalence type `circ_type2.right/1'.
-circ_type2.m:018: Error: circular equivalence type `circ_type2.circ_left/1'.
-circ_type2.m:019: Error: circular equivalence type `circ_type2.circ_right/1'.
+circ_type2.m:010: Error: circular equivalence type `circ_type2.circ1'/1.
+circ_type2.m:011: Error: circular equivalence type `circ_type2.circ2'/1.
+circ_type2.m:012: Error: circular equivalence type `circ_type2.circ3'/1.
+circ_type2.m:013: Error: circular equivalence type `circ_type2.circ4'/1.
+circ_type2.m:015: Error: circular equivalence type `circ_type2.left'/1.
+circ_type2.m:016: Error: circular equivalence type `circ_type2.right'/1.
+circ_type2.m:018: Error: circular equivalence type `circ_type2.circ_left'/1.
+circ_type2.m:019: Error: circular equivalence type `circ_type2.circ_right'/1.
Index: tests/invalid/circ_type3.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/circ_type3.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 circ_type3.err_exp
--- tests/invalid/circ_type3.err_exp	14 Sep 2005 05:26:43 -0000	1.3
+++ tests/invalid/circ_type3.err_exp	2 Sep 2006 12:59:16 -0000
@@ -1,3 +1,3 @@
-circ_type3.m:008: Error: circular equivalence type `circ_type3.circ/0'.
-circ_type3.m:010: Error: circular equivalence type `circ_type3.circ1/0'.
-circ_type3.m:012: Error: circular equivalence type `circ_type3.circ2/0'.
+circ_type3.m:008: Error: circular equivalence type `circ_type3.circ'/0.
+circ_type3.m:010: Error: circular equivalence type `circ_type3.circ1'/0.
+circ_type3.m:012: Error: circular equivalence type `circ_type3.circ2'/0.
Index: tests/invalid/circ_type5.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/circ_type5.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 circ_type5.err_exp
--- tests/invalid/circ_type5.err_exp	14 Sep 2005 05:26:43 -0000	1.3
+++ tests/invalid/circ_type5.err_exp	2 Sep 2006 12:59:16 -0000
@@ -1,2 +1,2 @@
-circ_type5.m:006: Error: circular equivalence type `circ_type5.c/1'.
-circ_type5.m:007: Error: circular equivalence type `circ_type5.c/0'.
+circ_type5.m:006: Error: circular equivalence type `circ_type5.c'/1.
+circ_type5.m:007: Error: circular equivalence type `circ_type5.c'/0.
Index: tests/invalid/complex_constraint_err.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/complex_constraint_err.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 complex_constraint_err.err_exp
--- tests/invalid/complex_constraint_err.err_exp	14 Jun 2006 08:14:52 -0000	1.3
+++ tests/invalid/complex_constraint_err.err_exp	5 Sep 2006 12:07:20 -0000
@@ -1,5 +1,5 @@
 complex_constraint_err.m:009: In declaration for predicate
-complex_constraint_err.m:009:   `complex_constraint_err.t/1':
+complex_constraint_err.m:009:   `complex_constraint_err.t'/1:
 complex_constraint_err.m:009:   error in type class constraints: type variable
 complex_constraint_err.m:009:   C occurs in the constraints, but is not
 complex_constraint_err.m:009:   determined by the predicate's argument types.
@@ -23,7 +23,7 @@
 complex_constraint_err.m:009:   See the "Functional dependencies" section of
 complex_constraint_err.m:009:   the reference manual for details.
 complex_constraint_err.m:013: In declaration for predicate
-complex_constraint_err.m:013:   `complex_constraint_err.u/1':
+complex_constraint_err.m:013:   `complex_constraint_err.u'/1:
 complex_constraint_err.m:013:   error in type class constraints: type variables
 complex_constraint_err.m:013:   Z and X occur in the constraints, but are not
 complex_constraint_err.m:013:   determined by the predicate's argument types.
Index: tests/invalid/conflicting_tabling_pragmas.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/conflicting_tabling_pragmas.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 conflicting_tabling_pragmas.err_exp
--- tests/invalid/conflicting_tabling_pragmas.err_exp	14 Sep 2005 05:26:44 -0000	1.3
+++ tests/invalid/conflicting_tabling_pragmas.err_exp	5 Sep 2006 12:07:21 -0000
@@ -1,5 +1,5 @@
 conflicting_tabling_pragmas.m:012: Error: function
-conflicting_tabling_pragmas.m:012:   `conflicting_tabling_pragmas.fac/1' has
+conflicting_tabling_pragmas.m:012:   `conflicting_tabling_pragmas.fac'/1 has
 conflicting_tabling_pragmas.m:012:   both memo and loop_check pragmas
 conflicting_tabling_pragmas.m:012:   specified. Only one kind of tabling pragma
 conflicting_tabling_pragmas.m:012:   may be applied to it.
Index: tests/invalid/constrained_poly_insts.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/constrained_poly_insts.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 constrained_poly_insts.err_exp
--- tests/invalid/constrained_poly_insts.err_exp	14 Jun 2006 08:14:52 -0000	1.9
+++ tests/invalid/constrained_poly_insts.err_exp	5 Sep 2006 12:07:21 -0000
@@ -3,15 +3,15 @@
 constrained_poly_insts.m:012: Error: inconsistent constraints on inst variables in function mode declaration: r(in(_1)) = out(_1 =< free).
 constrained_poly_insts.m:014: Error: inconsistent constraints on inst variables in function declaration: s((_1 :: in(_2 =< ground))) = (_1 :: out(_2 =< unique)).
 constrained_poly_insts.m:023: Error: clause for predicate
-constrained_poly_insts.m:023:   `constrained_poly_insts.q/2'
+constrained_poly_insts.m:023:   `constrained_poly_insts.q'/2
 constrained_poly_insts.m:023:   without preceding `pred' declaration.
 constrained_poly_insts.m:025: Error: clause for function
-constrained_poly_insts.m:025:   `constrained_poly_insts.s/1'
+constrained_poly_insts.m:025:   `constrained_poly_insts.s'/1
 constrained_poly_insts.m:025:   without preceding `func' declaration.
 constrained_poly_insts.m:023: Inferred :- pred q(T1, T1).
 constrained_poly_insts.m:025: Inferred :- func s(T1) = T1.
 constrained_poly_insts.m:006: Error: no mode declaration for exported predicate
-constrained_poly_insts.m:006:   `constrained_poly_insts.p/2'.
+constrained_poly_insts.m:006:   `constrained_poly_insts.p'/2.
 constrained_poly_insts.m:027: In clause for `t(in((I =< ground)), out((I =<
 constrained_poly_insts.m:027:   ground)))':
 constrained_poly_insts.m:027:   mode error: argument 2 became too instantiated.
@@ -19,6 +19,5 @@
 constrained_poly_insts.m:027:   `unique(42)',
 constrained_poly_insts.m:027:   expected final instantiatedness was `(I =<
 constrained_poly_insts.m:027:   ground)'.
-constrained_poly_insts.m:023: Error: no mode declaration for predicate
-constrained_poly_insts.m:023:   `constrained_poly_insts.q/2'.
+constrained_poly_insts.m:023: Error: no mode declaration for predicate `q'/2.
 For more information, recompile with `-E'.
Index: tests/invalid/constructor_warning.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/constructor_warning.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 constructor_warning.err_exp
--- tests/invalid/constructor_warning.err_exp	14 Sep 2005 05:26:44 -0000	1.3
+++ tests/invalid/constructor_warning.err_exp	5 Sep 2006 12:07:22 -0000
@@ -1,8 +1,8 @@
-constructor_warning.m:016: In clause for predicate `constructor_warning.bar/1':
+constructor_warning.m:016: In clause for predicate `bar'/1:
 constructor_warning.m:016:   in argument 1 of clause head:
-constructor_warning.m:016:   error: wrong number of arguments (0; should be 1 or 2)
-constructor_warning.m:016:   in use of constructor `foo_baz'.
-constructor_warning.m:017: In clause for predicate `constructor_warning.bar/1':
+constructor_warning.m:016:   error: wrong number of arguments (0; should be 1
+constructor_warning.m:016:   or 2) in use of constructor `foo_baz'.
+constructor_warning.m:017: In clause for predicate `bar'/1:
 constructor_warning.m:017:   in argument 1 of clause head:
 constructor_warning.m:017:   error: wrong number of arguments (1; should be 0)
 constructor_warning.m:017:   in use of constructor `fanta_fanta_fanta'.
Index: tests/invalid/det_atomic_goal_msgs.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/det_atomic_goal_msgs.err_exp,v
retrieving revision 1.1
diff -u -b -r1.1 det_atomic_goal_msgs.err_exp
--- tests/invalid/det_atomic_goal_msgs.err_exp	16 Jun 2006 07:24:42 -0000	1.1
+++ tests/invalid/det_atomic_goal_msgs.err_exp	5 Sep 2006 12:07:24 -0000
@@ -1,23 +1,23 @@
-det_atomic_goal_msgs.m:008: In `det_calls_failure(in, out)':
+det_atomic_goal_msgs.m:008: In `det_calls_failure'(in, out):
 det_atomic_goal_msgs.m:008:   error: determinism declaration not satisfied.
 det_atomic_goal_msgs.m:008:   Declared `det', inferred `failure'.
-det_atomic_goal_msgs.m:015:   call to `det_atomic_goal_msgs.failure_pred(in)'
+det_atomic_goal_msgs.m:015:   call to `det_atomic_goal_msgs.failure_pred'(in)
 det_atomic_goal_msgs.m:015:   can fail.
-det_atomic_goal_msgs.m:009: In `det_calls_semidet(in, out)':
+det_atomic_goal_msgs.m:009: In `det_calls_semidet'(in, out):
 det_atomic_goal_msgs.m:009:   error: determinism declaration not satisfied.
 det_atomic_goal_msgs.m:009:   Declared `det', inferred `semidet'.
-det_atomic_goal_msgs.m:016:   call to `det_atomic_goal_msgs.semidet_pred(in)'
+det_atomic_goal_msgs.m:016:   call to `det_atomic_goal_msgs.semidet_pred'(in)
 det_atomic_goal_msgs.m:016:   can fail.
-det_atomic_goal_msgs.m:010: In `det_calls_multi(out)':
+det_atomic_goal_msgs.m:010: In `det_calls_multi'(out):
 det_atomic_goal_msgs.m:010:   error: determinism declaration not satisfied.
 det_atomic_goal_msgs.m:010:   Declared `det', inferred `multi'.
-det_atomic_goal_msgs.m:017:   call to `det_atomic_goal_msgs.multi_pred(out)'
+det_atomic_goal_msgs.m:017:   call to `det_atomic_goal_msgs.multi_pred'(out)
 det_atomic_goal_msgs.m:017:   can succeed more than once.
-det_atomic_goal_msgs.m:011: In `det_calls_nondet(in, out)':
+det_atomic_goal_msgs.m:011: In `det_calls_nondet'(in, out):
 det_atomic_goal_msgs.m:011:   error: determinism declaration not satisfied.
 det_atomic_goal_msgs.m:011:   Declared `det', inferred `nondet'.
-det_atomic_goal_msgs.m:018:   call to `det_atomic_goal_msgs.nondet_pred(in,
-det_atomic_goal_msgs.m:018:   out)' can fail and can succeed more than once.
-det_atomic_goal_msgs.m:038: In `failure_pred(in)':
+det_atomic_goal_msgs.m:018:   call to `det_atomic_goal_msgs.nondet_pred'(in,
+det_atomic_goal_msgs.m:018:   out) can fail and can succeed more than once.
+det_atomic_goal_msgs.m:038: In `failure_pred'(in):
 det_atomic_goal_msgs.m:038:   error: determinism declaration not satisfied.
 det_atomic_goal_msgs.m:038:   Declared `failure', inferred `det'.
Index: tests/invalid/det_errors.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/det_errors.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 det_errors.err_exp
--- tests/invalid/det_errors.err_exp	28 Oct 2005 02:11:02 -0000	1.4
+++ tests/invalid/det_errors.err_exp	5 Sep 2006 12:07:25 -0000
@@ -1,22 +1,22 @@
-det_errors.m:005: In `p1(in)':
+det_errors.m:005: In `p1'(in):
 det_errors.m:005:   error: determinism declaration not satisfied.
 det_errors.m:005:   Declared `det', inferred `semidet'.
 det_errors.m:018:   In argument 1 of clause head:
 det_errors.m:018:   unification of `HeadVar__1' and `42' can fail.
-det_errors.m:006: In `p2(in)':
+det_errors.m:006: In `p2'(in):
 det_errors.m:006:   error: determinism declaration not satisfied.
 det_errors.m:006:   Declared `det', inferred `semidet'.
 det_errors.m:019:   Unification of `X' and `42' can fail.
-det_errors.m:007: In `p3(in)':
+det_errors.m:007: In `p3'(in):
 det_errors.m:007:   error: determinism declaration not satisfied.
 det_errors.m:007:   Declared `det', inferred `semidet'.
 det_errors.m:020:   Unification of `X' and `42' can fail.
-det_errors.m:008: In `p4(in)':
+det_errors.m:008: In `p4'(in):
 det_errors.m:008:   error: determinism declaration not satisfied.
 det_errors.m:008:   Declared `det', inferred `semidet'.
 det_errors.m:021:   In argument 2 of functor `+/2':
 det_errors.m:021:   unification with `21' can fail.
-det_errors.m:013: In `q(in, out)':
+det_errors.m:013: In `q'(in, out):
 det_errors.m:013:   error: determinism declaration not satisfied.
 det_errors.m:013:   Declared `det', inferred `semidet'.
 det_errors.m:024:   The switch on HeadVar__1 does not cover det_errors.d/0,
Index: tests/invalid/det_errors_cc.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/det_errors_cc.err_exp,v
retrieving revision 1.2
diff -u -b -r1.2 det_errors_cc.err_exp
--- tests/invalid/det_errors_cc.err_exp	27 Jan 2006 05:52:23 -0000	1.2
+++ tests/invalid/det_errors_cc.err_exp	5 Sep 2006 12:07:25 -0000
@@ -1,57 +1,57 @@
-det_errors_cc.m:013: Error: call to predicate `p1/2' with determinism
-det_errors_cc.m:013:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:013:   solutions.
+det_errors_cc.m:013: Error: call to predicate `det_errors_cc.p1'/2 with
+det_errors_cc.m:013:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:013:   requires all solutions.
 det_errors_cc.m:014:   Call to p2 can fail.
 det_errors_cc.m:015:   Call to p3 can fail.
 det_errors_cc.m:016:   Call to p4 can fail.
 det_errors_cc.m:017:   Call to p5 can fail.
 det_errors_cc.m:018:   Call to p6 can fail.
-det_errors_cc.m:014: Error: call to predicate `p2/2' with determinism
-det_errors_cc.m:014:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:014:   solutions.
+det_errors_cc.m:014: Error: call to predicate `det_errors_cc.p2'/2 with
+det_errors_cc.m:014:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:014:   requires all solutions.
 det_errors_cc.m:015:   Call to p3 can fail.
 det_errors_cc.m:016:   Call to p4 can fail.
 det_errors_cc.m:017:   Call to p5 can fail.
 det_errors_cc.m:018:   Call to p6 can fail.
-det_errors_cc.m:015: Error: call to predicate `p3/2' with determinism
-det_errors_cc.m:015:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:015:   solutions.
+det_errors_cc.m:015: Error: call to predicate `det_errors_cc.p3'/2 with
+det_errors_cc.m:015:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:015:   requires all solutions.
 det_errors_cc.m:016:   Call to p4 can fail.
 det_errors_cc.m:017:   Call to p5 can fail.
 det_errors_cc.m:018:   Call to p6 can fail.
-det_errors_cc.m:016: Error: call to predicate `p4/2' with determinism
-det_errors_cc.m:016:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:016:   solutions.
+det_errors_cc.m:016: Error: call to predicate `det_errors_cc.p4'/2 with
+det_errors_cc.m:016:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:016:   requires all solutions.
 det_errors_cc.m:017:   Call to p5 can fail.
 det_errors_cc.m:018:   Call to p6 can fail.
-det_errors_cc.m:017: Error: call to predicate `p5/2' with determinism
-det_errors_cc.m:017:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:017:   solutions.
+det_errors_cc.m:017: Error: call to predicate `det_errors_cc.p5'/2 with
+det_errors_cc.m:017:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:017:   requires all solutions.
 det_errors_cc.m:018:   Call to p6 can fail.
-det_errors_cc.m:023: Error: call to predicate `p3/2' with determinism
-det_errors_cc.m:023:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:023:   solutions.
+det_errors_cc.m:023: Error: call to predicate `det_errors_cc.p3'/2 with
+det_errors_cc.m:023:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:023:   requires all solutions.
 det_errors_cc.m:024:   Call to p4 can fail.
 det_errors_cc.m:025:   Unification of C with 10 can fail.
 det_errors_cc.m:026:   Unification of B and C can fail.
-det_errors_cc.m:024: Error: call to predicate `p4/2' with determinism
-det_errors_cc.m:024:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:024:   solutions.
+det_errors_cc.m:024: Error: call to predicate `det_errors_cc.p4'/2 with
+det_errors_cc.m:024:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:024:   requires all solutions.
 det_errors_cc.m:025:   Unification of C with 10 can fail.
 det_errors_cc.m:026:   Unification of B and C can fail.
-det_errors_cc.m:032: Error: call to predicate `p3/2' with determinism
-det_errors_cc.m:032:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:032:   solutions.
+det_errors_cc.m:032: Error: call to predicate `det_errors_cc.p3'/2 with
+det_errors_cc.m:032:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:032:   requires all solutions.
 det_errors_cc.m:034:   Fail goal can fail.
-det_errors_cc.m:042: Error: call to predicate `p2/2' with determinism
-det_errors_cc.m:042:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:042:   solutions.
+det_errors_cc.m:042: Error: call to predicate `det_errors_cc.p2'/2 with
+det_errors_cc.m:042:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:042:   requires all solutions.
 det_errors_cc.m:043:   Negated goal can fail.
-det_errors_cc.m:048: Error: call to predicate `p3/2' with determinism
-det_errors_cc.m:048:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:048:   solutions.
+det_errors_cc.m:048: Error: call to predicate `det_errors_cc.p3'/2 with
+det_errors_cc.m:048:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:048:   requires all solutions.
 det_errors_cc.m:050:   Higher-order predicate call can fail.
-det_errors_cc.m:055: Error: call to predicate `p1/2' with determinism
-det_errors_cc.m:055:   `cc_nondet' occurs in a context which requires all
-det_errors_cc.m:055:   solutions.
+det_errors_cc.m:055: Error: call to predicate `det_errors_cc.p1'/2 with
+det_errors_cc.m:055:   determinism `cc_nondet' occurs in a context which
+det_errors_cc.m:055:   requires all solutions.
 det_errors_cc.m:066:   Switch on C is incomplete.
Index: tests/invalid/duplicate_modes.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/duplicate_modes.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 duplicate_modes.err_exp
--- tests/invalid/duplicate_modes.err_exp	18 Aug 2005 07:57:58 -0000	1.9
+++ tests/invalid/duplicate_modes.err_exp	5 Sep 2006 12:07:26 -0000
@@ -6,21 +6,21 @@
 duplicate_modes.m:001:   would normally be a `:- pred', `:- func', `:- type',
 duplicate_modes.m:001:   `:- inst' or `:- mode' declaration.
 duplicate_modes.m:008: In mode declarations for predicate
-duplicate_modes.m:008:   `duplicate_modes.q/2':
+duplicate_modes.m:008:   `duplicate_modes.q'/2:
 duplicate_modes.m:008:   error: duplicate mode declaration.
 duplicate_modes.m:008:   Modes `q(in, out) is det' and
 duplicate_modes.m:008:   `q((ground >> ground), (free >> ground)) is det' are
 duplicate_modes.m:008:   indistinguishable.
 duplicate_modes.m:009:   Here is the conflicting mode declaration.
 duplicate_modes.m:008: In mode declarations for predicate
-duplicate_modes.m:008:   `duplicate_modes.q/2':
+duplicate_modes.m:008:   `duplicate_modes.q'/2:
 duplicate_modes.m:008:   error: duplicate mode declaration.
 duplicate_modes.m:008:   Modes `q(in, out) is det' and
 duplicate_modes.m:008:   `q((ground >> ground), (free >> ground)) is det' are
 duplicate_modes.m:008:   indistinguishable.
 duplicate_modes.m:010:   Here is the conflicting mode declaration.
 duplicate_modes.m:014: In mode declarations for predicate
-duplicate_modes.m:014:   `duplicate_modes.r/2':
+duplicate_modes.m:014:   `duplicate_modes.r'/2:
 duplicate_modes.m:014:   error: duplicate mode declaration.
 duplicate_modes.m:014:   Modes `r(in, in) is semidet' and `r(in, in) is det'
 duplicate_modes.m:014:   are indistinguishable.
Index: tests/invalid/erroneous_throw_promise.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/erroneous_throw_promise.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 erroneous_throw_promise.err_exp
--- tests/invalid/erroneous_throw_promise.err_exp	27 Jan 2006 05:52:23 -0000	1.4
+++ tests/invalid/erroneous_throw_promise.err_exp	5 Sep 2006 12:07:27 -0000
@@ -1,9 +1,9 @@
-erroneous_throw_promise.m:005: `foo(in)' has determinism erroneous but also has
+erroneous_throw_promise.m:005: `foo'(in) has determinism erroneous but also has
 erroneous_throw_promise.m:005:   foreign clauses that have a
 erroneous_throw_promise.m:005:   `will_not_throw_exception' attribute. This
 erroneous_throw_promise.m:005:   attribute cannot be applied to erroneous
 erroneous_throw_promise.m:005:   procedures.
-erroneous_throw_promise.m:007: `bar(in)' has determinism erroneous but also has
+erroneous_throw_promise.m:007: `bar'(in) has determinism erroneous but also has
 erroneous_throw_promise.m:007:   foreign clauses that have a
 erroneous_throw_promise.m:007:   `will_not_throw_exception' attribute. This
 erroneous_throw_promise.m:007:   attribute cannot be applied to erroneous
Index: tests/invalid/errors.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/errors.err_exp,v
retrieving revision 1.15
diff -u -b -r1.15 errors.err_exp
--- tests/invalid/errors.err_exp	14 Jun 2006 08:14:52 -0000	1.15
+++ tests/invalid/errors.err_exp	5 Sep 2006 12:07:28 -0000
@@ -12,27 +12,27 @@
 errors.m:053:   error: undefined type `undefined_type'/0.
 errors.m:100: In definition of type `errors.needs_qualification'/0:
 errors.m:100:   error: undefined type `state'/0.
-errors.m:055: Error: circular equivalence type `errors.circular_eqv_type/0'.
+errors.m:055: Error: circular equivalence type `errors.circular_eqv_type'/0.
 errors.m:057: Error: circular equivalence type
-errors.m:057:   `errors.indirectly_circular_eqv_type_1/0'.
+errors.m:057:   `errors.indirectly_circular_eqv_type_1'/0.
 errors.m:058: Error: circular equivalence type
-errors.m:058:   `errors.indirectly_circular_eqv_type_2/0'.
+errors.m:058:   `errors.indirectly_circular_eqv_type_2'/0.
 errors.m:028: Error: mode declaration for predicate
-errors.m:028:   `errors.mode_declaration_without_pred_declaration/0'
+errors.m:028:   `errors.mode_declaration_without_pred_declaration'/0
 errors.m:028:   without preceding `pred' declaration.
 errors.m:032: Error: mode declaration for predicate
-errors.m:032:   `errors.missing_pred_declaration/0'
+errors.m:032:   `errors.missing_pred_declaration'/0
 errors.m:032:   without preceding `pred' declaration.
 errors.m:049: Error: constructor `errors.a/0' for type
 errors.m:049:   `errors.type_with_multiply_defined_ctors/0' multiply defined.
 errors.m:049: Error: constructor `errors.f/1' for type
 errors.m:049:   `errors.type_with_multiply_defined_ctors/0' multiply defined.
 errors.m:038: Error: clause for predicate
-errors.m:038:   `errors.clause_without_pred_or_mode_declaration/0'
+errors.m:038:   `errors.clause_without_pred_or_mode_declaration'/0
 errors.m:038:   without preceding `pred' declaration.
 errors.m:075: In clause for predicate
-errors.m:075:   `errors.pred_with_unresolved_polymorphism/0':
+errors.m:075:   `errors.pred_with_unresolved_polymorphism'/0:
 errors.m:075:   warning: variable `Arg' occurs only once in this scope.
-errors.m:091: In clause for predicate `errors.pred_with_singleton_vars/1':
+errors.m:091: In clause for predicate `errors.pred_with_singleton_vars'/1:
 errors.m:091:   warning: variable `X' occurs only once in this scope.
 For more information, recompile with `-E'.
Index: tests/invalid/errors1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/errors1.err_exp,v
retrieving revision 1.12
diff -u -b -r1.12 errors1.err_exp
--- tests/invalid/errors1.err_exp	14 Jun 2006 08:14:52 -0000	1.12
+++ tests/invalid/errors1.err_exp	5 Sep 2006 12:07:28 -0000
@@ -6,27 +6,27 @@
 errors1.m:053: In definition of type
 errors1.m:053:   `errors1.eqv_type_which_references_undefined_type'/0:
 errors1.m:053:   error: undefined type `undefined_type'/0.
-errors1.m:055: Error: circular equivalence type `errors1.circular_eqv_type/0'.
+errors1.m:055: Error: circular equivalence type `errors1.circular_eqv_type'/0.
 errors1.m:057: Error: circular equivalence type
-errors1.m:057:   `errors1.indirectly_circular_eqv_type_1/0'.
+errors1.m:057:   `errors1.indirectly_circular_eqv_type_1'/0.
 errors1.m:058: Error: circular equivalence type
-errors1.m:058:   `errors1.indirectly_circular_eqv_type_2/0'.
+errors1.m:058:   `errors1.indirectly_circular_eqv_type_2'/0.
 errors1.m:028: Error: mode declaration for predicate
-errors1.m:028:   `errors1.mode_declaration_without_pred_declaration/0'
+errors1.m:028:   `errors1.mode_declaration_without_pred_declaration'/0
 errors1.m:028:   without preceding `pred' declaration.
 errors1.m:032: Error: mode declaration for predicate
-errors1.m:032:   `errors1.missing_pred_declaration/0'
+errors1.m:032:   `errors1.missing_pred_declaration'/0
 errors1.m:032:   without preceding `pred' declaration.
 errors1.m:049: Error: constructor `errors1.a/0' for type
 errors1.m:049:   `errors1.type_with_multiply_defined_ctors/0' multiply defined.
 errors1.m:049: Error: constructor `errors1.f/1' for type
 errors1.m:049:   `errors1.type_with_multiply_defined_ctors/0' multiply defined.
 errors1.m:038: Error: clause for predicate
-errors1.m:038:   `errors1.clause_without_pred_or_mode_declaration/0'
+errors1.m:038:   `errors1.clause_without_pred_or_mode_declaration'/0
 errors1.m:038:   without preceding `pred' declaration.
 errors1.m:072: In clause for predicate
-errors1.m:072:   `errors1.pred_with_unresolved_polymorphism/0':
+errors1.m:072:   `errors1.pred_with_unresolved_polymorphism'/0:
 errors1.m:072:   warning: variable `Arg' occurs only once in this scope.
-errors1.m:088: In clause for predicate `errors1.pred_with_singleton_vars/1':
+errors1.m:088: In clause for predicate `errors1.pred_with_singleton_vars'/1:
 errors1.m:088:   warning: variable `X' occurs only once in this scope.
 For more information, recompile with `-E'.
Index: tests/invalid/errors2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/errors2.err_exp,v
retrieving revision 1.14
diff -u -b -r1.14 errors2.err_exp
--- tests/invalid/errors2.err_exp	27 Jul 2006 05:03:48 -0000	1.14
+++ tests/invalid/errors2.err_exp	6 Sep 2006 04:34:00 -0000
@@ -5,125 +5,124 @@
 errors2.m:001:   in its interface section(s). This would normally be a
 errors2.m:001:   `:- pred', `:- func', `:- type', `:- inst' or `:- mode'
 errors2.m:001:   declaration.
-errors2.m:009: Error: clause for predicate `errors2.bind_type_param/1'
+errors2.m:009: Error: clause for predicate `errors2.bind_type_param'/1
 errors2.m:009:   without preceding `pred' declaration.
-errors2.m:052: In clause for predicate `errors2.type_error_4/0':
+errors2.m:052: In clause for predicate `errors2.type_error_4'/0:
 errors2.m:052:   warning: variable `X' occurs only once in this scope.
-errors2.m:059: In clause for predicate `errors2.type_error_5/0':
+errors2.m:059: In clause for predicate `errors2.type_error_5'/0:
 errors2.m:059:   warning: variable `X' occurs only once in this scope.
-errors2.m:065: In clause for predicate `errors2.type_error_6/0':
+errors2.m:065: In clause for predicate `errors2.type_error_6'/0:
 errors2.m:065:   warning: variable `X' occurs only once in this scope.
-errors2.m:070: In clause for predicate `errors2.type_error_7/0':
+errors2.m:070: In clause for predicate `errors2.type_error_7'/0:
 errors2.m:070:   warning: variable `Y' occurs only once in this scope.
-errors2.m:071: In clause for predicate `errors2.type_error_7/0':
+errors2.m:071: In clause for predicate `errors2.type_error_7'/0:
 errors2.m:071:   warning: variables `Z, A, B' occur only once in this scope.
-errors2.m:031: In clause for predicate `errors2.type_error/0':
-errors2.m:031:   in argument 1 of call to predicate `expect_int/1':
+errors2.m:007: Error: no clauses for predicate `bind_type_param'/2.
+errors2.m:023: Error: no clauses for predicate `produce_string'/1.
+errors2.m:025: Error: no clauses for predicate `expect_int'/1.
+errors2.m:031: In clause for predicate `type_error'/0:
+errors2.m:031:   in argument 1 of call to predicate `expect_int'/1:
 errors2.m:031:   type error: variable `X' has type `string',
 errors2.m:031:   expected type was `int'.
-	The partial type assignment was:
-	X_1: string
-
-errors2.m:037: In clause for predicate `errors2.type_error_2/0':
+errors2.m:031:   The partial type assignment was:
+errors2.m:031:     X_1: string
+errors2.m:037: In clause for predicate `type_error_2'/0:
 errors2.m:037:   type error in unification of variable `X'
 errors2.m:037:   and variable `Y'.
 errors2.m:037:   `X' has type `string',
 errors2.m:037:   `Y' has type `int'.
-	The partial type assignment was:
-	X_1: string
-	Y_2: int
-
-errors2.m:043: In clause for predicate `errors2.type_error_3/0':
-errors2.m:043:   in argument 1 of call to predicate `expect_int/1':
+errors2.m:037:   The partial type assignment was:
+errors2.m:037:     X_1: string
+errors2.m:037:     Y_2: int
+errors2.m:043: In clause for predicate `type_error_3'/0:
+errors2.m:043:   in argument 1 of call to predicate `expect_int'/1:
 errors2.m:043:   type error: variable `Y' has type `string',
 errors2.m:043:   expected type was `int'.
-	The partial type assignment was:
-	X_1: string
-	Y_2: string
-
-errors2.m:052: In clause for predicate `errors2.type_error_4/0':
+errors2.m:043:   The partial type assignment was:
+errors2.m:043:     X_1: string
+errors2.m:043:     Y_2: string
+errors2.m:052: In clause for predicate `type_error_4'/0:
 errors2.m:052:   in argument 3 of functor `foo_functor/3':
 errors2.m:052:   type error in unification of argument
 errors2.m:052:   and constant `1.00000000000000'.
 errors2.m:052:   argument has type `string',
 errors2.m:052:   constant `1.00000000000000' has type `float'.
-	The partial type assignment was:
-	Y_1: int
-	X_2: (errors2.foo_type)
-	V_3: character
-	V_4: string
-
-errors2.m:059: In clause for predicate `errors2.type_error_5/0':
+errors2.m:052:   The partial type assignment was:
+errors2.m:052:     Y_1: int
+errors2.m:052:     X_2: (errors2.foo_type)
+errors2.m:052:     V_3: character
+errors2.m:052:     V_4: string
+errors2.m:059: In clause for predicate `type_error_5'/0:
 errors2.m:059:   in argument 3 of functor `foo_functor/3':
 errors2.m:059:   type error in unification of argument
 errors2.m:059:   and constant `1.00000000000000'.
 errors2.m:059:   argument has type `string',
 errors2.m:059:   constant `1.00000000000000' has type `float'.
-	The partial type assignment was:
-	Y_1: character
-	X_2: (errors2.foo_type)
-	V_3: int
-	V_4: string
-
-errors2.m:065: In clause for predicate `errors2.type_error_6/0':
+errors2.m:059:   The partial type assignment was:
+errors2.m:059:     Y_1: character
+errors2.m:059:     X_2: (errors2.foo_type)
+errors2.m:059:     V_3: int
+errors2.m:059:     V_4: string
+errors2.m:065: In clause for predicate `type_error_6'/0:
 errors2.m:065:   in argument 3 of functor `bar_functor/3':
 errors2.m:065:   type error in unification of argument
 errors2.m:065:   and constant `1.00000000000000'.
 errors2.m:065:   argument has type `string',
 errors2.m:065:   constant `1.00000000000000' has type `float'.
-	The partial type assignment was:
-	Y_1: character
-	X_2: (errors2.bar_1_type)
-	V_3: int
-	V_4: string
-
-errors2.m:072: In clause for predicate `errors2.type_error_7/0':
-errors2.m:072:   in argument 1 of call to predicate `expect_int/1':
+errors2.m:065:   The partial type assignment was:
+errors2.m:065:     Y_1: character
+errors2.m:065:     X_2: (errors2.bar_1_type)
+errors2.m:065:     V_3: int
+errors2.m:065:     V_4: string
+errors2.m:072: In clause for predicate `type_error_7'/0:
+errors2.m:072:   in argument 1 of call to predicate `expect_int'/1:
 errors2.m:072:   type error: variable `C' has type `string',
 errors2.m:072:   expected type was `int'.
-	The possible partial type assignments were:
-	Y_1: (errors2.foo)
-	Z_2: (errors2.bar_1_type)
-	A_3: int
-	B_4: character
-	C_5: string
-
-	Y_1: (errors2.foo)
-	Z_2: (errors2.bar_2_type)
-	A_3: character
-	B_4: int
-	C_5: string
-
-	Y_1: character
-	Z_2: (errors2.bar_1_type)
-	A_3: int
-	B_4: character
-	C_5: string
-
-	Y_1: character
-	Z_2: (errors2.bar_2_type)
-	A_3: character
-	B_4: int
-	C_5: string
-
-errors2.m:078: In clause for predicate `errors2.type_error_8/0':
-errors2.m:078:   in argument 1 of call to predicate `from_char_list/2':
+errors2.m:072:   The possible partial type assignments were:
+errors2.m:072:     Type assignment 1:
+errors2.m:072:     Y_1: (errors2.foo)
+errors2.m:072:     Z_2: (errors2.bar_1_type)
+errors2.m:072:     A_3: int
+errors2.m:072:     B_4: character
+errors2.m:072:     C_5: string
+errors2.m:072:     
+errors2.m:072:     Type assignment 2:
+errors2.m:072:     Y_1: (errors2.foo)
+errors2.m:072:     Z_2: (errors2.bar_2_type)
+errors2.m:072:     A_3: character
+errors2.m:072:     B_4: int
+errors2.m:072:     C_5: string
+errors2.m:072:     
+errors2.m:072:     Type assignment 3:
+errors2.m:072:     Y_1: character
+errors2.m:072:     Z_2: (errors2.bar_1_type)
+errors2.m:072:     A_3: int
+errors2.m:072:     B_4: character
+errors2.m:072:     C_5: string
+errors2.m:072:     
+errors2.m:072:     Type assignment 4:
+errors2.m:072:     Y_1: character
+errors2.m:072:     Z_2: (errors2.bar_2_type)
+errors2.m:072:     A_3: character
+errors2.m:072:     B_4: int
+errors2.m:072:     C_5: string
+errors2.m:078: In clause for predicate `type_error_8'/0:
+errors2.m:078:   in argument 1 of call to predicate `from_char_list'/2:
 errors2.m:078:   error: undefined symbol `[]/0'.
-errors2.m:078: In clause for predicate `errors2.type_error_8/0':
-errors2.m:078:   error: undefined predicate `from_char_list/2'.
-errors2.m:085: In clause for predicate `errors2.type_error_9/0':
+errors2.m:078: In clause for predicate `type_error_8'/0:
+errors2.m:078:   error: undefined predicate `from_char_list'/2.
+errors2.m:085: In clause for predicate `type_error_9'/0:
 errors2.m:085:   type error in unification of variable `X'
 errors2.m:085:   and variable `Y'.
 errors2.m:085:   `X' has type `{int, string, character}',
 errors2.m:085:   `Y' has type `{string, character, int}'.
-	The partial type assignment was:
-	X_1: {int, string, character}
-	Y_2: {string, character, int}
-	V_3: int
-	V_4: string
-	V_5: character
-	V_6: string
-	V_7: character
-	V_8: int
-
+errors2.m:085:   The partial type assignment was:
+errors2.m:085:     X_1: {int, string, character}
+errors2.m:085:     Y_2: {string, character, int}
+errors2.m:085:     V_3: int
+errors2.m:085:     V_4: string
+errors2.m:085:     V_5: character
+errors2.m:085:     V_6: string
+errors2.m:085:     V_7: character
+errors2.m:085:     V_8: int
 errors2.m:009: Inferred :- pred bind_type_param(int).
Index: tests/invalid/errors2.err_exp2
===================================================================
RCS file: tests/invalid/errors2.err_exp2
diff -N tests/invalid/errors2.err_exp2
--- tests/invalid/errors2.err_exp2	14 Sep 2005 05:26:44 -0000	1.9
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,63 +0,0 @@
-errors2.m:001: Warning: interface for module `errors2' does not export
-errors2.m:001:   anything.
-errors2.m:009: Error: clause for predicate `errors2.bind_type_param/1'
-errors2.m:009:   without preceding `pred' declaration.
-errors2.m:052: In clause for predicate `errors2.type_error_4/0':
-errors2.m:052:   warning: variable `X' occurs only once in this scope.
-errors2.m:059: In clause for predicate `errors2.type_error_5/0':
-errors2.m:059:   warning: variable `X' occurs only once in this scope.
-errors2.m:065: In clause for predicate `errors2.type_error_6/0':
-errors2.m:065:   warning: variable `X' occurs only once in this scope.
-errors2.m:070: In clause for predicate `errors2.type_error_7/0':
-errors2.m:070:   warning: variable `Y' occurs only once in this scope.
-errors2.m:071: In clause for predicate `errors2.type_error_7/0':
-errors2.m:071:   warning: variables `Z, A, B' occur only once in this scope.
-errors2.m:007: Error: no clauses for predicate `bind_type_param/2'.
-errors2.m:023: Error: no clauses for predicate `produce_string/1'.
-errors2.m:025: Error: no clauses for predicate `expect_int/1'.
-errors2.m:031: In clause for predicate `errors2.type_error/0':
-errors2.m:031:   in argument 1 of call to predicate `expect_int/1':
-errors2.m:031:   type error: variable `X' has type `string',
-errors2.m:031:   expected type was `int'.
-errors2.m:037: In clause for predicate `errors2.type_error_2/0':
-errors2.m:037:   type error in unification of variable `X'
-errors2.m:037:   and variable `Y'.
-errors2.m:037:   `X' has type `string',
-errors2.m:037:   `Y' has type `int'.
-errors2.m:043: In clause for predicate `errors2.type_error_3/0':
-errors2.m:043:   in argument 1 of call to predicate `expect_int/1':
-errors2.m:043:   type error: variable `Y' has type `string',
-errors2.m:043:   expected type was `int'.
-errors2.m:052: In clause for predicate `errors2.type_error_4/0':
-errors2.m:052:   in argument 3 of functor `foo_functor/3':
-errors2.m:052:   type error in unification of argument
-errors2.m:052:   and constant `1.00000000000000'.
-errors2.m:052:   argument has type `string',
-errors2.m:052:   constant `1.00000000000000' has type `float'.
-errors2.m:059: In clause for predicate `errors2.type_error_5/0':
-errors2.m:059:   in argument 3 of functor `foo_functor/3':
-errors2.m:059:   type error in unification of argument
-errors2.m:059:   and constant `1.00000000000000'.
-errors2.m:059:   argument has type `string',
-errors2.m:059:   constant `1.00000000000000' has type `float'.
-errors2.m:065: In clause for predicate `errors2.type_error_6/0':
-errors2.m:065:   in argument 3 of functor `bar_functor/3':
-errors2.m:065:   type error in unification of argument
-errors2.m:065:   and constant `1.00000000000000'.
-errors2.m:065:   argument has type `string',
-errors2.m:065:   constant `1.00000000000000' has type `float'.
-errors2.m:072: In clause for predicate `errors2.type_error_7/0':
-errors2.m:072:   in argument 1 of call to predicate `expect_int/1':
-errors2.m:072:   type error: variable `C' has type `string',
-errors2.m:072:   expected type was `int'.
-errors2.m:078: In clause for predicate `errors2.type_error_8/0':
-errors2.m:078:   in argument 1 of call to predicate `from_char_list/2':
-errors2.m:078:   error: undefined symbol `[]/0'.
-errors2.m:078: In clause for predicate `errors2.type_error_8/0':
-errors2.m:078:   error: undefined predicate `from_char_list/2'.
-errors2.m:085: In clause for predicate `errors2.type_error_9/0':
-errors2.m:085:   type error in unification of variable `X'
-errors2.m:085:   and variable `Y'.
-errors2.m:085:   `X' has type `{int, string, character}',
-errors2.m:085:   `Y' has type `{string, character, int}'.
-errors2.m:009: Inferred :- pred bind_type_param(int).
Index: tests/invalid/exist_foreign_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/exist_foreign_error.err_exp,v
retrieving revision 1.1
diff -u -b -r1.1 exist_foreign_error.err_exp
--- tests/invalid/exist_foreign_error.err_exp	14 Oct 2005 01:42:56 -0000	1.1
+++ tests/invalid/exist_foreign_error.err_exp	5 Sep 2006 12:07:29 -0000
@@ -1,3 +1,3 @@
 exist_foreign_error.m:025: The foreign language code for function
-exist_foreign_error.m:025:   `exist_foreign_error.get_pti_from_arg_types/2'
+exist_foreign_error.m:025:   `exist_foreign_error.get_pti_from_arg_types'/2
 exist_foreign_error.m:025:   should define the variable `TypeInfo_for_T'.
Index: tests/invalid/exported_mode.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/exported_mode.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 exported_mode.err_exp
--- tests/invalid/exported_mode.err_exp	14 Sep 2005 05:26:44 -0000	1.3
+++ tests/invalid/exported_mode.err_exp	5 Sep 2006 12:07:30 -0000
@@ -1,3 +1,3 @@
-exported_mode.m:004: Error: mode declaration for predicate `exported_mode.p/2'
+exported_mode.m:004: Error: mode declaration for predicate `exported_mode.p'/2
 exported_mode.m:004:   without preceding `pred' declaration.
 exported_mode.m:004: Inferred :- pred p(T1, string).
Index: tests/invalid/exported_unify.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/exported_unify.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 exported_unify.err_exp
--- tests/invalid/exported_unify.err_exp	14 Sep 2005 05:26:45 -0000	1.3
+++ tests/invalid/exported_unify.err_exp	7 Sep 2006 04:20:23 -0000
@@ -1,2 +1,3 @@
-exported_unify2.int:003: In clause for unification predicate for type exported_unify2.foo:
-exported_unify2.int:003:   error: undefined predicate `exported_unify2.unify_foo/2'.
+exported_unify2.int:003: In clause for unification predicate for type `foo':
+exported_unify2.int:003:   error: undefined predicate
+exported_unify2.int:003:   `exported_unify2.unify_foo'/2.
Index: tests/invalid/exported_unify3.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/exported_unify3.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 exported_unify3.err_exp
--- tests/invalid/exported_unify3.err_exp	14 Sep 2005 05:26:45 -0000	1.3
+++ tests/invalid/exported_unify3.err_exp	7 Sep 2006 04:20:24 -0000
@@ -1,6 +1,10 @@
-exported_unify3.m:005: In clause for unification predicate for type exported_unify3.foo:
-exported_unify3.m:005:   error: undefined predicate `exported_unify3.defined_in_wrong_module/2'.
-exported_unify3.sub.int:003: In clause for unification predicate for type exported_unify3.sub.bar:
-exported_unify3.sub.int:003:   error: undefined predicate `exported_unify3.sub.not_exported/2'.
-exported_unify3.int0:003: In clause for unification predicate for type exported_unify3.foo:
-exported_unify3.int0:003:   error: undefined predicate `exported_unify3.defined_in_wrong_module/2'.
+exported_unify3.m:005: In clause for unification predicate for type `foo':
+exported_unify3.m:005:   error: undefined predicate
+exported_unify3.m:005:   `exported_unify3.defined_in_wrong_module'/2.
+exported_unify3.sub.int:003: In clause for unification predicate for type
+exported_unify3.sub.int:003:   `bar':
+exported_unify3.sub.int:003:   error: undefined predicate
+exported_unify3.sub.int:003:   `exported_unify3.sub.not_exported'/2.
+exported_unify3.int0:003: In clause for unification predicate for type `foo':
+exported_unify3.int0:003:   error: undefined predicate
+exported_unify3.int0:003:   `exported_unify3.defined_in_wrong_module'/2.
Index: tests/invalid/ext_type.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ext_type.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 ext_type.err_exp
--- tests/invalid/ext_type.err_exp	14 Jun 2006 08:14:52 -0000	1.5
+++ tests/invalid/ext_type.err_exp	6 Sep 2006 04:37:06 -0000
@@ -1,25 +1,23 @@
-ext_type.m:016: In clause for predicate `ext_type.p/2':
+ext_type.m:016: In clause for predicate `p'/2:
 ext_type.m:016:   type error in unification of variable `Z'
 ext_type.m:016:   and functor `q/1'.
 ext_type.m:016:   variable `Z' has type `(some [QT] QT)',
 ext_type.m:016:   functor `q/1' has type 
 ext_type.m:016:   `q(int): (some [QT] QT)'.
-	The partial type assignment was:
-	some [QT_2]
-	HeadVar__1_1: (bool.bool)
-	HeadVar__2_2: QT
-	Y_3: QT
-	V_4: int
-	Z_5: QT
-
-ext_type.m:019: In clause for predicate `ext_type.r/0':
+ext_type.m:016:   The partial type assignment was:
+ext_type.m:016:     some [QT_2]
+ext_type.m:016:     HeadVar__1_1: (bool.bool)
+ext_type.m:016:     HeadVar__2_2: QT
+ext_type.m:016:     Y_3: QT
+ext_type.m:016:     V_4: int
+ext_type.m:016:     Z_5: QT
+ext_type.m:019: In clause for predicate `r'/0:
 ext_type.m:019:   type error in unification of argument
 ext_type.m:019:   and functor `q/1'.
 ext_type.m:019:   argument has type `(some [QT] QT)',
 ext_type.m:019:   functor `q/1' has type 
 ext_type.m:019:   `q(int): (some [QT] QT)'.
-	The partial type assignment was:
-	some [QT_1]
-	V_1: QT
-	V_2: int
-
+ext_type.m:019:   The partial type assignment was:
+ext_type.m:019:     some [QT_1]
+ext_type.m:019:     V_1: QT
+ext_type.m:019:     V_2: int
Index: tests/invalid/ext_type_bug.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ext_type_bug.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 ext_type_bug.err_exp
--- tests/invalid/ext_type_bug.err_exp	14 Jun 2006 08:14:52 -0000	1.6
+++ tests/invalid/ext_type_bug.err_exp	6 Sep 2006 04:38:55 -0000
@@ -1,8 +1,8 @@
-ext_type_bug.m:011: In clause for predicate `ext_type_bug.foo/1':
-ext_type_bug.m:011:   in argument 1 of call to predicate `make_bar/1':
-ext_type_bug.m:011:   type error: variable `Bar' has type `(ext_type_bug.bar(int))',
+ext_type_bug.m:011: In clause for predicate `foo'/1:
+ext_type_bug.m:011:   in argument 1 of call to predicate `make_bar'/1:
+ext_type_bug.m:011:   type error: variable `Bar' has type
+ext_type_bug.m:011:   `(ext_type_bug.bar(int))',
 ext_type_bug.m:011:   expected type was `(some [T] (ext_type_bug.bar(T)))'.
-	The partial type assignment was:
-	some [T_1]
-	Bar_2: (ext_type_bug.bar(int))
-
+ext_type_bug.m:011:   The partial type assignment was:
+ext_type_bug.m:011:     some [T_1]
+ext_type_bug.m:011:     Bar_2: (ext_type_bug.bar(int))
Index: tests/invalid/external.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/external.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 external.err_exp
--- tests/invalid/external.err_exp	14 Sep 2005 05:26:45 -0000	1.5
+++ tests/invalid/external.err_exp	5 Sep 2006 12:07:31 -0000
@@ -1,2 +1,2 @@
 external.m:012: Warning: `external' declaration requires arity.
-external.m:007: Error: no clauses for predicate `p/2'.
+external.m:007: Error: no clauses for predicate `p'/2.
Index: tests/invalid/field_syntax_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/field_syntax_error.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 field_syntax_error.err_exp
--- tests/invalid/field_syntax_error.err_exp	14 Sep 2005 05:26:45 -0000	1.4
+++ tests/invalid/field_syntax_error.err_exp	5 Sep 2006 12:07:32 -0000
@@ -1,26 +1,31 @@
-field_syntax_error.m:013: In clause for function `field_syntax_error.baz/1':
+field_syntax_error.m:013: In clause for function `field_syntax_error.baz'/1:
 field_syntax_error.m:013:   warning: variable `Bar' occurs only once in this
 field_syntax_error.m:013:   scope.
-field_syntax_error.m:015: In clause for function `field_syntax_error.baz3/1':
+field_syntax_error.m:015: In clause for function `field_syntax_error.baz3'/1:
 field_syntax_error.m:015:   warning: variable `Bar' occurs only once in this
 field_syntax_error.m:015:   scope.
-field_syntax_error.m:013: In clause for function `field_syntax_error.baz/1':
+field_syntax_error.m:013: In clause for function `baz'/1:
 field_syntax_error.m:013:   in function result term of clause head:
-field_syntax_error.m:013:   error: invalid use of field selection operator (`^').
-field_syntax_error.m:014: In clause for function `field_syntax_error.baz2/1':
+field_syntax_error.m:013:   error: invalid use of field selection operator
+field_syntax_error.m:013:   (`^').
+field_syntax_error.m:014: In clause for function `baz2'/1:
 field_syntax_error.m:014:   in function result term of clause head:
-field_syntax_error.m:014:   error: invalid use of field selection operator (`^').
-field_syntax_error.m:015: In clause for function `field_syntax_error.baz3/1':
+field_syntax_error.m:014:   error: invalid use of field selection operator
+field_syntax_error.m:014:   (`^').
+field_syntax_error.m:015: In clause for function `baz3'/1:
 field_syntax_error.m:015:   in function result term of clause head:
 field_syntax_error.m:015:   error: invalid use of field update operator (`:=').
-field_syntax_error.m:015: In clause for function `field_syntax_error.baz3/1':
+field_syntax_error.m:015: In clause for function `baz3'/1:
 field_syntax_error.m:015:   in function result term of clause head:
 field_syntax_error.m:015:   in argument 1 of functor `:=/2':
-field_syntax_error.m:015:   error: invalid use of field selection operator (`^').
-field_syntax_error.m:016: In clause for function `field_syntax_error.baz4/1':
+field_syntax_error.m:015:   error: invalid use of field selection operator
+field_syntax_error.m:015:   (`^').
+field_syntax_error.m:016: In clause for function `baz4'/1:
 field_syntax_error.m:016:   in function result term of clause head:
 field_syntax_error.m:016:   error: invalid use of field update operator (`:=').
-field_syntax_error.m:016: In clause for function `field_syntax_error.baz4/1':
+field_syntax_error.m:016: In clause for function `baz4'/1:
 field_syntax_error.m:016:   in function result term of clause head:
 field_syntax_error.m:016:   in argument 1 of functor `:=/2':
-field_syntax_error.m:016:   error: invalid use of field selection operator (`^').
+field_syntax_error.m:016:   error: invalid use of field selection operator
+field_syntax_error.m:016:   (`^').
+For more information, recompile with `-E'.
Index: tests/invalid/foreign_purity_mismatch.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/foreign_purity_mismatch.err_exp,v
retrieving revision 1.1
diff -u -b -r1.1 foreign_purity_mismatch.err_exp
--- tests/invalid/foreign_purity_mismatch.err_exp	10 Jul 2006 04:40:56 -0000	1.1
+++ tests/invalid/foreign_purity_mismatch.err_exp	5 Sep 2006 12:07:33 -0000
@@ -23,16 +23,16 @@
 foreign_purity_mismatch.m:055:   has purity semipure but that predicate has
 foreign_purity_mismatch.m:055:   been declared impure.
 foreign_purity_mismatch.m:006: In predicate
-foreign_purity_mismatch.m:006:   `foreign_purity_mismatch.pure_with_impure/1':
+foreign_purity_mismatch.m:006:   `foreign_purity_mismatch.pure_with_impure'/1:
 foreign_purity_mismatch.m:006:   purity error: predicate is impure.
 foreign_purity_mismatch.m:006:   It must be declared `impure' or promised pure.
 foreign_purity_mismatch.m:007: In predicate
-foreign_purity_mismatch.m:007:   `foreign_purity_mismatch.pure_with_semipure/1':
+foreign_purity_mismatch.m:007:   `foreign_purity_mismatch.pure_with_semipure'/1:
 foreign_purity_mismatch.m:007:   purity error: predicate is semipure.
 foreign_purity_mismatch.m:007:   It must be declared `semipure' or promised
 foreign_purity_mismatch.m:007:   pure.
 foreign_purity_mismatch.m:009: In predicate
-foreign_purity_mismatch.m:009:   `foreign_purity_mismatch.semipure_with_impure/1':
+foreign_purity_mismatch.m:009:   `foreign_purity_mismatch.semipure_with_impure'/1:
 foreign_purity_mismatch.m:009:   purity error: predicate is impure.
 foreign_purity_mismatch.m:009:   It must be declared `impure' or promised
 foreign_purity_mismatch.m:009:   semipure.
Index: tests/invalid/foreign_singleton.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/foreign_singleton.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 foreign_singleton.err_exp
--- tests/invalid/foreign_singleton.err_exp	14 Sep 2005 05:26:45 -0000	1.5
+++ tests/invalid/foreign_singleton.err_exp	5 Sep 2006 12:07:33 -0000
@@ -1,12 +1,12 @@
-foreign_singleton.m:021: In the C code for predicate `foreign_singleton.f/3':
+foreign_singleton.m:021: In the C code for predicate `foreign_singleton.f'/3:
 foreign_singleton.m:021:   warning: variable `IO0' does not occur in the C
 foreign_singleton.m:021:   code.
-foreign_singleton.m:026: In clause for predicate `foreign_singleton.f/3':
+foreign_singleton.m:026: In clause for predicate `foreign_singleton.f'/3:
 foreign_singleton.m:026:   warning: variable `X' occurs only once in this
 foreign_singleton.m:026:   scope.
-foreign_singleton.m:030: In clause for predicate `foreign_singleton.g/3':
+foreign_singleton.m:030: In clause for predicate `foreign_singleton.g'/3:
 foreign_singleton.m:030:   warning: variable `X' occurs only once in this
 foreign_singleton.m:030:   scope.
-foreign_singleton.m:032: In the C code for predicate `foreign_singleton.g/3':
+foreign_singleton.m:032: In the C code for predicate `foreign_singleton.g'/3:
 foreign_singleton.m:032:   warning: variable `IO0' does not occur in the C
 foreign_singleton.m:032:   code.
Index: tests/invalid/foreign_type_2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/foreign_type_2.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 foreign_type_2.err_exp
--- tests/invalid/foreign_type_2.err_exp	14 Sep 2005 05:26:45 -0000	1.4
+++ tests/invalid/foreign_type_2.err_exp	5 Sep 2006 12:07:34 -0000
@@ -1,4 +1,4 @@
-foreign_type_2.m:018: In clause for function `foreign_type_2.unwrap_foreign/1':
+foreign_type_2.m:018: In clause for function `unwrap_foreign'/1:
 foreign_type_2.m:018:   in argument 1 of clause head:
 foreign_type_2.m:018:   error: undefined symbol `foreign/1'.
 foreign_type_2.m:018:   There are `:- pragma foreign_type' declarations for
Index: tests/invalid/foreign_type_visibility.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/foreign_type_visibility.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 foreign_type_visibility.err_exp
--- tests/invalid/foreign_type_visibility.err_exp	14 Sep 2005 05:26:45 -0000	1.3
+++ tests/invalid/foreign_type_visibility.err_exp	2 Sep 2006 12:59:33 -0000
@@ -1,11 +1,11 @@
 foreign_type_visibility.m:009: Error: pragma foreign_type
-foreign_type_visibility.m:009:   `foreign_type_visibility.foreign/0' must have
+foreign_type_visibility.m:009:   `foreign_type_visibility.foreign'/0 must have
 foreign_type_visibility.m:009:   the same visibility as the type declaration.
 foreign_type_visibility.m:020: In definition of type
-foreign_type_visibility.m:020:   `foreign_type_visibility.foreign2/0':
+foreign_type_visibility.m:020:   `foreign_type_visibility.foreign2'/0:
 foreign_type_visibility.m:020:   error: all definitions of a type must have the
 foreign_type_visibility.m:020:   same visibility
 foreign_type_visibility.m:022: In definition of type
-foreign_type_visibility.m:022:   `foreign_type_visibility.foreign3/0':
+foreign_type_visibility.m:022:   `foreign_type_visibility.foreign3'/0:
 foreign_type_visibility.m:022:   error: all definitions of a type must have the
 foreign_type_visibility.m:022:   same visibility
Index: tests/invalid/freefree.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/freefree.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 freefree.err_exp
--- tests/invalid/freefree.err_exp	14 Jun 2006 08:14:53 -0000	1.4
+++ tests/invalid/freefree.err_exp	5 Sep 2006 12:07:35 -0000
@@ -1,4 +1,4 @@
-freefree.m:016: In predicate `freefree.p/0':
+freefree.m:016: In predicate `freefree.p'/0:
 freefree.m:016:   warning: unresolved polymorphism.
 freefree.m:016:   The variables with unbound types were:
 freefree.m:016:       Y: V_1
Index: tests/invalid/funcs_as_preds.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/funcs_as_preds.err_exp,v
retrieving revision 1.11
diff -u -b -r1.11 funcs_as_preds.err_exp
--- tests/invalid/funcs_as_preds.err_exp	14 Jun 2006 08:14:53 -0000	1.11
+++ tests/invalid/funcs_as_preds.err_exp	6 Sep 2006 14:42:39 -0000
@@ -1,21 +1,21 @@
 funcs_as_preds.m:001: Warning: interface for module `funcs_as_preds' does not
 funcs_as_preds.m:001:   export anything.
-funcs_as_preds.m:017: Error: clause for function `funcs_as_preds.null/1'
+funcs_as_preds.m:017: Error: clause for function `funcs_as_preds.null'/1
 funcs_as_preds.m:017:   without preceding `func' declaration.
-funcs_as_preds.m:021: Error: clause for function `funcs_as_preds.car/1'
+funcs_as_preds.m:021: Error: clause for function `funcs_as_preds.car'/1
 funcs_as_preds.m:021:   without preceding `func' declaration.
-funcs_as_preds.m:024: Error: clause for function `funcs_as_preds.cdr/1'
+funcs_as_preds.m:024: Error: clause for function `funcs_as_preds.cdr'/1
 funcs_as_preds.m:024:   without preceding `func' declaration.
-funcs_as_preds.m:027: Error: clause for function `funcs_as_preds.cons/2'
+funcs_as_preds.m:027: Error: clause for function `funcs_as_preds.cons'/2
 funcs_as_preds.m:027:   without preceding `func' declaration.
-funcs_as_preds.m:030: Error: clause for function `funcs_as_preds.ap/2'
+funcs_as_preds.m:030: Error: clause for function `funcs_as_preds.ap'/2
 funcs_as_preds.m:030:   without preceding `func' declaration.
-funcs_as_preds.m:017: In clause for function `funcs_as_preds.null/1':
+funcs_as_preds.m:017: In clause for function `null'/1:
 funcs_as_preds.m:017:   in function result term of clause head:
-funcs_as_preds.m:017:   error: the language construct =/2 should be
-funcs_as_preds.m:017:   used as a goal, not as an expression.
-funcs_as_preds.m:030: In clause for function `funcs_as_preds.ap/2':
-funcs_as_preds.m:030:   error: undefined predicate `null/1'.
+funcs_as_preds.m:017:   error: the language construct `='/2 should be used as a
+funcs_as_preds.m:017:   goal, not as an expression.
+funcs_as_preds.m:030: In clause for function `ap'/2:
+funcs_as_preds.m:030:   error: undefined predicate `null'/1.
 funcs_as_preds.m:030:   (There is a *function* with that name, however.
 funcs_as_preds.m:030:   Perhaps you forgot to add ` = ...'?)
 funcs_as_preds.m:021: Inferred :- func car((list.list((list.list(T))))) = (list.list(T)).
Index: tests/invalid/hawkins_mm_fail_reset.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/hawkins_mm_fail_reset.err_exp,v
retrieving revision 1.2
diff -u -b -r1.2 hawkins_mm_fail_reset.err_exp
--- tests/invalid/hawkins_mm_fail_reset.err_exp	12 Jul 2006 06:15:40 -0000	1.2
+++ tests/invalid/hawkins_mm_fail_reset.err_exp	5 Sep 2006 12:07:39 -0000
@@ -4,7 +4,7 @@
 hawkins_mm_fail_reset.m:036: Error: `pragma minimal_model' declaration not
 hawkins_mm_fail_reset.m:036:   allowed for procedure with determinism
 hawkins_mm_fail_reset.m:036:   `failure'.
-hawkins_mm_fail_reset.m:020: In `entry(out)':
+hawkins_mm_fail_reset.m:020: In `entry'(out):
 hawkins_mm_fail_reset.m:020:   warning: determinism declaration could be
 hawkins_mm_fail_reset.m:020:   tighter.
 hawkins_mm_fail_reset.m:020:   Declared `nondet', inferred `failure'.
Index: tests/invalid/ho_default_func_1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ho_default_func_1.err_exp,v
retrieving revision 1.8
diff -u -b -r1.8 ho_default_func_1.err_exp
--- tests/invalid/ho_default_func_1.err_exp	14 Jun 2006 08:14:53 -0000	1.8
+++ tests/invalid/ho_default_func_1.err_exp	5 Sep 2006 12:07:39 -0000
@@ -2,7 +2,7 @@
 ho_default_func_1.m:029:   mode error in conjunction. The next 2 error messages
 ho_default_func_1.m:029:   indicate possible causes of this error.
 ho_default_func_1.m:029:   In clause for `baz(in, out)':
-ho_default_func_1.m:029:   in call to function `univ.univ/1':
+ho_default_func_1.m:029:   in call to function `univ.univ'/1:
 ho_default_func_1.m:029:   mode error: arguments `TypeInfo_13, V_7, V_6' have
 ho_default_func_1.m:029:   the following insts:
 ho_default_func_1.m:029:     unique(private_builtin.type_info(unique(<type_ctor_info
@@ -13,13 +13,13 @@
 ho_default_func_1.m:029:     ground) is det),
 ho_default_func_1.m:029:     free
 ho_default_func_1.m:029:   which does not match any of the modes for function
-ho_default_func_1.m:029:   `univ.univ/1'.
+ho_default_func_1.m:029:   `univ.univ'/1.
 ho_default_func_1.m:029:   In clause for `baz(in, out)':
-ho_default_func_1.m:029:   in call to predicate `univ.univ_to_type/2':
+ho_default_func_1.m:029:   in call to predicate `univ.univ_to_type'/2:
 ho_default_func_1.m:029:   mode error: arguments `TypeInfo_for_T, V_6, Y0' have
 ho_default_func_1.m:029:   the following insts:
 ho_default_func_1.m:029:     ground,
 ho_default_func_1.m:029:     free,
 ho_default_func_1.m:029:     free
 ho_default_func_1.m:029:   which does not match any of the modes for predicate
-ho_default_func_1.m:029:   `univ.univ_to_type/2'.
+ho_default_func_1.m:029:   `univ.univ_to_type'/2.
Index: tests/invalid/ho_default_func_2.sub.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ho_default_func_2.sub.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 ho_default_func_2.sub.err_exp
--- tests/invalid/ho_default_func_2.sub.err_exp	14 Jun 2006 08:14:53 -0000	1.7
+++ tests/invalid/ho_default_func_2.sub.err_exp	5 Sep 2006 12:06:47 -0000
@@ -1,8 +1,7 @@
 ho_default_func_2.sub.m:014: In clause for `baz(out)':
 ho_default_func_2.sub.m:014:   in argument 1 of call to function
-ho_default_func_2.sub.m:014:   `ho_default_func_2.id.mkid/1':
+ho_default_func_2.sub.m:014:   `ho_default_func_2.id.mkid'/1:
 ho_default_func_2.sub.m:014:   mode error: variable `V_2' has instantiatedness
 ho_default_func_2.sub.m:014:   `/* unique */(func((free >> ground)) = (ground
 ho_default_func_2.sub.m:014:   >> ground) is det)',
 ho_default_func_2.sub.m:014:   expected instantiatedness was `ground'.
-For more information, recompile with `-E'.
Index: tests/invalid/ho_default_func_3.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ho_default_func_3.err_exp,v
retrieving revision 1.8
diff -u -b -r1.8 ho_default_func_3.err_exp
--- tests/invalid/ho_default_func_3.err_exp	14 Jun 2006 08:14:53 -0000	1.8
+++ tests/invalid/ho_default_func_3.err_exp	5 Sep 2006 12:07:40 -0000
@@ -2,7 +2,7 @@
 ho_default_func_3.m:029:   mode error in conjunction. The next 2 error messages
 ho_default_func_3.m:029:   indicate possible causes of this error.
 ho_default_func_3.m:029:   In clause for `baz(in, out)':
-ho_default_func_3.m:029:   in call to function `univ.univ/1':
+ho_default_func_3.m:029:   in call to function `univ.univ'/1:
 ho_default_func_3.m:029:   mode error: arguments `TypeInfo_13, V_7, V_6' have
 ho_default_func_3.m:029:   the following insts:
 ho_default_func_3.m:029:     unique(private_builtin.type_info(unique(<type_ctor_info
@@ -13,13 +13,13 @@
 ho_default_func_3.m:029:     >> unique) is det),
 ho_default_func_3.m:029:     free
 ho_default_func_3.m:029:   which does not match any of the modes for function
-ho_default_func_3.m:029:   `univ.univ/1'.
+ho_default_func_3.m:029:   `univ.univ'/1.
 ho_default_func_3.m:029:   In clause for `baz(in, out)':
-ho_default_func_3.m:029:   in call to predicate `univ.univ_to_type/2':
+ho_default_func_3.m:029:   in call to predicate `univ.univ_to_type'/2:
 ho_default_func_3.m:029:   mode error: arguments `TypeInfo_for_T, V_6, Y0' have
 ho_default_func_3.m:029:   the following insts:
 ho_default_func_3.m:029:     ground,
 ho_default_func_3.m:029:     free,
 ho_default_func_3.m:029:     free
 ho_default_func_3.m:029:   which does not match any of the modes for predicate
-ho_default_func_3.m:029:   `univ.univ_to_type/2'.
+ho_default_func_3.m:029:   `univ.univ_to_type'/2.
Index: tests/invalid/ho_type_mode_bug.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ho_type_mode_bug.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 ho_type_mode_bug.err_exp
--- tests/invalid/ho_type_mode_bug.err_exp	14 Jun 2006 08:14:53 -0000	1.6
+++ tests/invalid/ho_type_mode_bug.err_exp	5 Sep 2006 12:07:40 -0000
@@ -11,7 +11,7 @@
 ho_type_mode_bug.m:025:   expecting higher-order pred inst (of arity 5).
 ho_type_mode_bug.m:026:   In clause for `my_foldl2((pred(in, in, out) is det),
 ho_type_mode_bug.m:026:   in, in, out, in, out)':
-ho_type_mode_bug.m:026:   in call to predicate `ho_type_mode_bug.my_foldl2/6':
+ho_type_mode_bug.m:026:   in call to predicate `ho_type_mode_bug.my_foldl2'/6:
 ho_type_mode_bug.m:026:   mode error: arguments
 ho_type_mode_bug.m:026:   `TypeInfo_for_X, TypeInfo_for_Y, TypeInfo_for_Z, P, T, FirstAcc1, FirstAcc, SecAcc1, SecAcc'
 ho_type_mode_bug.m:026:   have the following insts:
@@ -25,7 +25,7 @@
 ho_type_mode_bug.m:026:     free,
 ho_type_mode_bug.m:026:     free
 ho_type_mode_bug.m:026:   which does not match any of the modes for predicate
-ho_type_mode_bug.m:026:   `ho_type_mode_bug.my_foldl2/6'.
+ho_type_mode_bug.m:026:   `ho_type_mode_bug.my_foldl2'/6.
 ho_type_mode_bug.m:024:   In clause for `my_foldl2((pred(in, in, out) is det),
 ho_type_mode_bug.m:024:   in, in, out, in, out)':
 ho_type_mode_bug.m:024:   in argument 4 of clause head:
@@ -52,7 +52,7 @@
 ho_type_mode_bug.m:025:   expecting higher-order pred inst (of arity 5).
 ho_type_mode_bug.m:026:   In clause for `my_foldl2((pred(in, in, out) is det),
 ho_type_mode_bug.m:026:   in, in, out, di, uo)':
-ho_type_mode_bug.m:026:   in call to predicate `ho_type_mode_bug.my_foldl2/6':
+ho_type_mode_bug.m:026:   in call to predicate `ho_type_mode_bug.my_foldl2'/6:
 ho_type_mode_bug.m:026:   mode error: arguments
 ho_type_mode_bug.m:026:   `TypeInfo_for_X, TypeInfo_for_Y, TypeInfo_for_Z, P, T, FirstAcc1, FirstAcc, SecAcc1, SecAcc'
 ho_type_mode_bug.m:026:   have the following insts:
@@ -66,7 +66,7 @@
 ho_type_mode_bug.m:026:     free,
 ho_type_mode_bug.m:026:     free
 ho_type_mode_bug.m:026:   which does not match any of the modes for predicate
-ho_type_mode_bug.m:026:   `ho_type_mode_bug.my_foldl2/6'.
+ho_type_mode_bug.m:026:   `ho_type_mode_bug.my_foldl2'/6.
 ho_type_mode_bug.m:024:   In clause for `my_foldl2((pred(in, in, out) is det),
 ho_type_mode_bug.m:024:   in, in, out, di, uo)':
 ho_type_mode_bug.m:024:   in argument 4 of clause head:
Index: tests/invalid/ho_unique_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/ho_unique_error.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 ho_unique_error.err_exp
--- tests/invalid/ho_unique_error.err_exp	14 Jun 2006 08:14:53 -0000	1.6
+++ tests/invalid/ho_unique_error.err_exp	5 Sep 2006 12:07:41 -0000
@@ -1,4 +1,4 @@
-ho_unique_error.m:007: In `call_ho(di, uo)':
+ho_unique_error.m:007: In `call_ho'(di, uo):
 ho_unique_error.m:007:   error: invalid determinism for a predicate with I/O
 ho_unique_error.m:007:   state arguments.
 ho_unique_error.m:012: In clause for `call_ho(di, uo)':
Index: tests/invalid/illtyped_compare.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/illtyped_compare.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 illtyped_compare.err_exp
--- tests/invalid/illtyped_compare.err_exp	14 Jun 2006 08:14:53 -0000	1.4
+++ tests/invalid/illtyped_compare.err_exp	7 Sep 2006 04:21:08 -0000
@@ -1,36 +1,40 @@
-illtyped_compare.m:017: In clause for unification predicate for type illtyped_compare.bar_rep:
-illtyped_compare.m:017:   in argument 2 of call to predicate `illtyped_compare.compare_bar/3':
-illtyped_compare.m:017:   type error: variable `HeadVar__1' has type `(illtyped_compare.bar_rep)',
+illtyped_compare.m:017: In clause for unification predicate for type `bar_rep':
+illtyped_compare.m:017:   in argument 2 of call to predicate
+illtyped_compare.m:017:   `illtyped_compare.compare_bar'/3:
+illtyped_compare.m:017:   type error: variable `HeadVar__1' has type
+illtyped_compare.m:017:   `(illtyped_compare.bar_rep)',
 illtyped_compare.m:017:   expected type was `(illtyped_compare.bar)'.
-	The partial type assignment was:
-	HeadVar__1_1: (illtyped_compare.bar_rep)
-	HeadVar__2_2: (illtyped_compare.bar_rep)
-	V_3: comparison_result
-
-illtyped_compare.m:017: In clause for unification predicate for type illtyped_compare.bar_rep:
-illtyped_compare.m:017:   in argument 3 of call to predicate `illtyped_compare.compare_bar/3':
-illtyped_compare.m:017:   type error: variable `HeadVar__2' has type `(illtyped_compare.bar_rep)',
+illtyped_compare.m:017:   The partial type assignment was:
+illtyped_compare.m:017:     HeadVar__1_1: (illtyped_compare.bar_rep)
+illtyped_compare.m:017:     HeadVar__2_2: (illtyped_compare.bar_rep)
+illtyped_compare.m:017:     V_3: comparison_result
+illtyped_compare.m:017: In clause for unification predicate for type `bar_rep':
+illtyped_compare.m:017:   in argument 3 of call to predicate
+illtyped_compare.m:017:   `illtyped_compare.compare_bar'/3:
+illtyped_compare.m:017:   type error: variable `HeadVar__2' has type
+illtyped_compare.m:017:   `(illtyped_compare.bar_rep)',
 illtyped_compare.m:017:   expected type was `(illtyped_compare.bar)'.
-	The partial type assignment was:
-	HeadVar__1_1: (illtyped_compare.bar_rep)
-	HeadVar__2_2: (illtyped_compare.bar_rep)
-	V_3: comparison_result
-
-illtyped_compare.m:017: In clause for comparison predicate for type illtyped_compare.bar_rep:
-illtyped_compare.m:017:   in argument 2 of call to predicate `illtyped_compare.compare_bar/3':
-illtyped_compare.m:017:   type error: variable `HeadVar__2' has type `(illtyped_compare.bar_rep)',
+illtyped_compare.m:017:   The partial type assignment was:
+illtyped_compare.m:017:     HeadVar__1_1: (illtyped_compare.bar_rep)
+illtyped_compare.m:017:     HeadVar__2_2: (illtyped_compare.bar_rep)
+illtyped_compare.m:017:     V_3: comparison_result
+illtyped_compare.m:017: In clause for comparison predicate for type `bar_rep':
+illtyped_compare.m:017:   in argument 2 of call to predicate
+illtyped_compare.m:017:   `illtyped_compare.compare_bar'/3:
+illtyped_compare.m:017:   type error: variable `HeadVar__2' has type
+illtyped_compare.m:017:   `(illtyped_compare.bar_rep)',
 illtyped_compare.m:017:   expected type was `(illtyped_compare.bar)'.
-	The partial type assignment was:
-	HeadVar__1_1: comparison_result
-	HeadVar__2_2: (illtyped_compare.bar_rep)
-	HeadVar__3_3: (illtyped_compare.bar_rep)
-
-illtyped_compare.m:017: In clause for comparison predicate for type illtyped_compare.bar_rep:
-illtyped_compare.m:017:   in argument 3 of call to predicate `illtyped_compare.compare_bar/3':
-illtyped_compare.m:017:   type error: variable `HeadVar__3' has type `(illtyped_compare.bar_rep)',
+illtyped_compare.m:017:   The partial type assignment was:
+illtyped_compare.m:017:     HeadVar__1_1: comparison_result
+illtyped_compare.m:017:     HeadVar__2_2: (illtyped_compare.bar_rep)
+illtyped_compare.m:017:     HeadVar__3_3: (illtyped_compare.bar_rep)
+illtyped_compare.m:017: In clause for comparison predicate for type `bar_rep':
+illtyped_compare.m:017:   in argument 3 of call to predicate
+illtyped_compare.m:017:   `illtyped_compare.compare_bar'/3:
+illtyped_compare.m:017:   type error: variable `HeadVar__3' has type
+illtyped_compare.m:017:   `(illtyped_compare.bar_rep)',
 illtyped_compare.m:017:   expected type was `(illtyped_compare.bar)'.
-	The partial type assignment was:
-	HeadVar__1_1: comparison_result
-	HeadVar__2_2: (illtyped_compare.bar_rep)
-	HeadVar__3_3: (illtyped_compare.bar_rep)
-
+illtyped_compare.m:017:   The partial type assignment was:
+illtyped_compare.m:017:     HeadVar__1_1: comparison_result
+illtyped_compare.m:017:     HeadVar__2_2: (illtyped_compare.bar_rep)
+illtyped_compare.m:017:     HeadVar__3_3: (illtyped_compare.bar_rep)
Index: tests/invalid/import_in_parent.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/import_in_parent.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 import_in_parent.err_exp
--- tests/invalid/import_in_parent.err_exp	14 Sep 2005 05:26:46 -0000	1.4
+++ tests/invalid/import_in_parent.err_exp	5 Sep 2006 12:06:47 -0000
@@ -1,2 +1,2 @@
-import_in_parent.m:021: In clause for predicate `import_in_parent.sub.foo/1':
-import_in_parent.m:021:   error: undefined predicate `bool.foo/1'.
+import_in_parent.m:021: In clause for predicate `foo'/1:
+import_in_parent.m:021:   error: undefined predicate `bool.foo'/1.
Index: tests/invalid/imported_mode.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/imported_mode.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 imported_mode.err_exp
--- tests/invalid/imported_mode.err_exp	14 Sep 2005 05:26:46 -0000	1.4
+++ tests/invalid/imported_mode.err_exp	5 Sep 2006 12:06:48 -0000
@@ -1,4 +1,4 @@
 exported_mode.int:003: Error: mode declaration for predicate
-exported_mode.int:003:   `exported_mode.p/2'
+exported_mode.int:003:   `exported_mode.p'/2
 exported_mode.int:003:   without preceding `pred' declaration.
 exported_mode.int:003: Inferred :- pred p(T1, T2).
Index: tests/invalid/impure_method_impl.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/impure_method_impl.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 impure_method_impl.err_exp
--- tests/invalid/impure_method_impl.err_exp	14 Sep 2005 05:26:46 -0000	1.7
+++ tests/invalid/impure_method_impl.err_exp	5 Sep 2006 12:07:42 -0000
@@ -1,12 +1,12 @@
 impure_method_impl.m:022: In call to impure predicate
-impure_method_impl.m:022:   `impure_method_impl.foo_m2/2':
+impure_method_impl.m:022:   `impure_method_impl.foo_m2'/2:
 impure_method_impl.m:022:   purity error: call must be preceded by `impure'
 impure_method_impl.m:022:   indicator.
 impure_method_impl.m:022: In type class method implementation:
 impure_method_impl.m:022:   purity error: predicate is impure.
 impure_method_impl.m:022:   It must be declared `impure' or promised semipure.
 impure_method_impl.m:021: In call to semipure predicate
-impure_method_impl.m:021:   `impure_method_impl.foo_m1/2':
+impure_method_impl.m:021:   `impure_method_impl.foo_m1'/2:
 impure_method_impl.m:021:   purity error: call must be preceded by `semipure'
 impure_method_impl.m:021:   indicator.
 impure_method_impl.m:021: In type class method implementation:
Index: tests/invalid/invalid_main.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/invalid_main.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 invalid_main.err_exp
--- tests/invalid/invalid_main.err_exp	16 Jan 2006 03:08:15 -0000	1.3
+++ tests/invalid/invalid_main.err_exp	5 Sep 2006 12:07:47 -0000
@@ -1,5 +1,5 @@
 invalid_main.m:004: Error: arguments of main/2 must have type `io.state'.
-invalid_main.m:004: In `main(di, out)':
+invalid_main.m:004: In `main'(di, out):
 invalid_main.m:004:   warning: determinism declaration could be tighter.
 invalid_main.m:004:   Declared `multi', inferred `det'.
 invalid_main.m:004: Error: main/2 must be `det' or `cc_multi'.
Index: tests/invalid/invalid_new.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/invalid_new.err_exp,v
retrieving revision 1.2
diff -u -b -r1.2 invalid_new.err_exp
--- tests/invalid/invalid_new.err_exp	14 Sep 2005 05:26:47 -0000	1.2
+++ tests/invalid/invalid_new.err_exp	5 Sep 2006 12:07:47 -0000
@@ -1,4 +1,4 @@
-invalid_new.m:020: In clause for function `invalid_new.nc/1':
+invalid_new.m:020: In clause for function `nc'/1:
 invalid_new.m:020:   in function result term of clause head:
 invalid_new.m:020:   error: undefined symbol `new c/1'.
 invalid_new.m:020:   Invalid use of `new' on a constructor of type
Index: tests/invalid/io_in_ite_cond.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/io_in_ite_cond.err_exp,v
retrieving revision 1.12
diff -u -b -r1.12 io_in_ite_cond.err_exp
--- tests/invalid/io_in_ite_cond.err_exp	14 Jun 2006 08:14:53 -0000	1.12
+++ tests/invalid/io_in_ite_cond.err_exp	5 Sep 2006 12:07:48 -0000
@@ -1,7 +1,6 @@
 io_in_ite_cond.m:016: In clause for `main(di, uo)':
 io_in_ite_cond.m:016:   in argument 1 of call to predicate
-io_in_ite_cond.m:016:   `io_in_ite_cond.foo/2':
+io_in_ite_cond.m:016:   `io_in_ite_cond.foo'/2:
 io_in_ite_cond.m:016:   mode error: variable `DCG_0' has instantiatedness
 io_in_ite_cond.m:016:   `mostly_unique',
 io_in_ite_cond.m:016:   expected instantiatedness was `unique'.
-For more information, recompile with `-E'.
Index: tests/invalid/lambda_syntax_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/lambda_syntax_error.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 lambda_syntax_error.err_exp
--- tests/invalid/lambda_syntax_error.err_exp	14 Sep 2005 05:26:47 -0000	1.3
+++ tests/invalid/lambda_syntax_error.err_exp	5 Sep 2006 12:07:50 -0000
@@ -1,56 +1,57 @@
-lambda_syntax_error.m:012: In clause for function `lambda_syntax_error.baz/1':
+lambda_syntax_error.m:012: In clause for function `baz'/1:
 lambda_syntax_error.m:012:   in function result term of clause head:
 lambda_syntax_error.m:012:   syntax error in lambda expression (`:-').
-lambda_syntax_error.m:012: In clause for function `lambda_syntax_error.baz/1':
+lambda_syntax_error.m:012: In clause for function `baz'/1:
 lambda_syntax_error.m:012:   in function result term of clause head:
 lambda_syntax_error.m:012:   in argument 1 of functor `:-/2':
 lambda_syntax_error.m:012:   error: undefined symbol `pred/1'.
-lambda_syntax_error.m:013: In clause for function `lambda_syntax_error.baz2/1':
+lambda_syntax_error.m:013: In clause for function `baz2'/1:
 lambda_syntax_error.m:013:   in function result term of clause head:
 lambda_syntax_error.m:013:   syntax error in lambda expression (`:-').
-lambda_syntax_error.m:013: In clause for function `lambda_syntax_error.baz2/1':
+lambda_syntax_error.m:013: In clause for function `baz2'/1:
 lambda_syntax_error.m:013:   in function result term of clause head:
 lambda_syntax_error.m:013:   in argument 1 of functor `:-/2':
 lambda_syntax_error.m:013:   error: undefined symbol `pred/1'.
-lambda_syntax_error.m:013: In clause for function `lambda_syntax_error.baz2/1':
+lambda_syntax_error.m:013: In clause for function `baz2'/1:
 lambda_syntax_error.m:013:   in function result term of clause head:
 lambda_syntax_error.m:013:   in argument 1 of functor `:-/2':
 lambda_syntax_error.m:013:   in argument 1 of functor `pred/1':
 lambda_syntax_error.m:013:   error: undefined symbol `::/2'.
-lambda_syntax_error.m:013: In clause for function `lambda_syntax_error.baz2/1':
+lambda_syntax_error.m:013: In clause for function `baz2'/1:
 lambda_syntax_error.m:013:   in function result term of clause head:
 lambda_syntax_error.m:013:   in argument 1 of functor `:-/2':
 lambda_syntax_error.m:013:   in argument 1 of functor `pred/1':
 lambda_syntax_error.m:013:   in argument 2 of functor `::/2':
 lambda_syntax_error.m:013:   error: undefined symbol `in/0'.
-lambda_syntax_error.m:014: In clause for function `lambda_syntax_error.baz3/1':
+lambda_syntax_error.m:014: In clause for function `baz3'/1:
 lambda_syntax_error.m:014:   in function result term of clause head:
 lambda_syntax_error.m:014:   syntax error in lambda expression (`:-').
-lambda_syntax_error.m:014: In clause for function `lambda_syntax_error.baz3/1':
+lambda_syntax_error.m:014: In clause for function `baz3'/1:
 lambda_syntax_error.m:014:   in function result term of clause head:
 lambda_syntax_error.m:014:   in argument 1 of functor `:-/2':
 lambda_syntax_error.m:014:   in argument 1 of functor `is/2':
 lambda_syntax_error.m:014:   error: undefined symbol `pred/1'.
-lambda_syntax_error.m:014: In clause for function `lambda_syntax_error.baz3/1':
+lambda_syntax_error.m:014: In clause for function `baz3'/1:
 lambda_syntax_error.m:014:   in function result term of clause head:
 lambda_syntax_error.m:014:   in argument 1 of functor `:-/2':
 lambda_syntax_error.m:014:   in argument 2 of functor `is/2':
 lambda_syntax_error.m:014:   error: undefined symbol `semidet/0'.
-lambda_syntax_error.m:015: In clause for function `lambda_syntax_error.baz4/1':
+lambda_syntax_error.m:015: In clause for function `baz4'/1:
 lambda_syntax_error.m:015:   in function result term of clause head:
 lambda_syntax_error.m:015:   syntax error in lambda expression (`:-').
-lambda_syntax_error.m:015: In clause for function `lambda_syntax_error.baz4/1':
+lambda_syntax_error.m:015: In clause for function `baz4'/1:
 lambda_syntax_error.m:015:   in function result term of clause head:
 lambda_syntax_error.m:015:   in argument 1 of functor `:-/2':
-lambda_syntax_error.m:015:   error: the language construct =/2 should be
-lambda_syntax_error.m:015:   used as a goal, not as an expression.
-lambda_syntax_error.m:015: In clause for function `lambda_syntax_error.baz4/1':
+lambda_syntax_error.m:015:   error: the language construct `='/2 should be used
+lambda_syntax_error.m:015:   as a goal, not as an expression.
+lambda_syntax_error.m:015: In clause for function `baz4'/1:
 lambda_syntax_error.m:015:   in function result term of clause head:
 lambda_syntax_error.m:015:   in argument 1 of functor `:-/2':
 lambda_syntax_error.m:015:   in argument 1 of functor `=/2':
 lambda_syntax_error.m:015:   error: undefined symbol `pred/1'.
-lambda_syntax_error.m:015: In clause for function `lambda_syntax_error.baz4/1':
+lambda_syntax_error.m:015: In clause for function `baz4'/1:
 lambda_syntax_error.m:015:   in function result term of clause head:
 lambda_syntax_error.m:015:   in argument 2 of functor `:-/2':
-lambda_syntax_error.m:015:   error: the language construct =/2 should be
-lambda_syntax_error.m:015:   used as a goal, not as an expression.
+lambda_syntax_error.m:015:   error: the language construct `='/2 should be used
+lambda_syntax_error.m:015:   as a goal, not as an expression.
+For more information, recompile with `-E'.
Index: tests/invalid/loopcheck.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/loopcheck.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 loopcheck.err_exp
--- tests/invalid/loopcheck.err_exp	12 Jul 2006 06:15:40 -0000	1.5
+++ tests/invalid/loopcheck.err_exp	5 Sep 2006 12:07:50 -0000
@@ -1,4 +1,4 @@
-loopcheck.m:009: In `main(di, uo)':
+loopcheck.m:009: In `main'(di, uo):
 loopcheck.m:009:   warning: determinism declaration could be tighter.
 loopcheck.m:009:   Declared `det', inferred `erroneous'.
 loopcheck.m:016: Error: `pragma loop_check' declaration not allowed for
@@ -6,7 +6,7 @@
 loopcheck.m:016:   The pragma requested is only valid for the following
 loopcheck.m:016:   determinisms: cc_multi, cc_nondet, det, multi, nondet and
 loopcheck.m:016:   semidet.
-loopcheck.m:017: Warning: recursive call will lead to infinite recursion. If
-loopcheck.m:017:   this recursive call is executed, the procedure will call
+loopcheck.m:017: Warning: recursive call will lead to infinite recursion.
+loopcheck.m:017:   If this recursive call is executed, the procedure will call
 loopcheck.m:017:   itself with exactly the same input arguments, leading to
 loopcheck.m:017:   infinite recursion.
Index: tests/invalid/magicbox.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/magicbox.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 magicbox.err_exp
--- tests/invalid/magicbox.err_exp	28 Oct 2005 02:11:03 -0000	1.5
+++ tests/invalid/magicbox.err_exp	5 Sep 2006 12:07:51 -0000
@@ -1,5 +1,5 @@
-magicbox.m:036: In `arguments_handler(di, uo, out)':
+magicbox.m:036: In `arguments_handler'(di, uo, out):
 magicbox.m:036:   error: determinism declaration not satisfied.
 magicbox.m:036:   Declared `cc_multi', inferred `cc_nondet'.
-magicbox.m:055:   call to `string.to_int(in, out)' can fail.
-magicbox.m:062:   call to `string.to_int(in, out)' can fail.
+magicbox.m:055:   call to `string.to_int'(in, out) can fail.
+magicbox.m:062:   call to `string.to_int'(in, out) can fail.
Index: tests/invalid/make_opt_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/make_opt_error.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 make_opt_error.err_exp
--- tests/invalid/make_opt_error.err_exp	14 Jun 2006 08:14:54 -0000	1.4
+++ tests/invalid/make_opt_error.err_exp	5 Sep 2006 12:07:51 -0000
@@ -1,12 +1,12 @@
 make_opt_error.m:014: Error: clause for automatically generated field access
-make_opt_error.m:014:   function `make_opt_error.x/1'.
+make_opt_error.m:014:   function `make_opt_error.x'/1.
 make_opt_error.m:014:   Clauses for field access functions are automatically
 make_opt_error.m:014:   generated by the compiler. To supply your own
 make_opt_error.m:014:   definition for a field access function, for example to
 make_opt_error.m:014:   check the input to a field update, give the field of
 make_opt_error.m:014:   the constructor a different name.
 make_opt_error.m:015: Error: clause for automatically generated field access
-make_opt_error.m:015:   function `make_opt_error.y/1'.
+make_opt_error.m:015:   function `make_opt_error.y'/1.
 make_opt_error.m:015:   Clauses for field access functions are automatically
 make_opt_error.m:015:   generated by the compiler. To supply your own
 make_opt_error.m:015:   definition for a field access function, for example to
Index: tests/invalid/merge_ground_any.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/merge_ground_any.err_exp,v
retrieving revision 1.8
diff -u -b -r1.8 merge_ground_any.err_exp
--- tests/invalid/merge_ground_any.err_exp	14 Jun 2006 08:14:54 -0000	1.8
+++ tests/invalid/merge_ground_any.err_exp	2 Sep 2006 12:59:50 -0000
@@ -8,4 +8,3 @@
 merge_ground_any.m:013:   merge_ground_any.'-'(ground, any))',
 merge_ground_any.m:013:   expected final instantiatedness was
 merge_ground_any.m:013:   `bound(merge_ground_any.'-'(ground, any))'.
-For more information, recompile with `-E'.
Index: tests/invalid/method_impl.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/method_impl.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 method_impl.err_exp
--- tests/invalid/method_impl.err_exp	14 Jun 2006 08:14:54 -0000	1.4
+++ tests/invalid/method_impl.err_exp	6 Sep 2006 14:42:49 -0000
@@ -1,10 +1,9 @@
 method_impl.m:022: In clause for type class method implementation:
-method_impl.m:022:   in argument 2 of predicate `foo_m1/2':
+method_impl.m:022:   in argument 2 of predicate `foo_m1'/2:
 method_impl.m:022:   type error: variable `HeadVar__2' has type `int',
 method_impl.m:022:   expected type was `string'.
-	The partial type assignment was:
-	HeadVar__1_1: (method_impl.foo)
-	HeadVar__2_2: int
-
+method_impl.m:022:   The partial type assignment was:
+method_impl.m:022:     HeadVar__1_1: (method_impl.foo)
+method_impl.m:022:     HeadVar__2_2: int
 method_impl.m:025: In clause for type class method implementation:
-method_impl.m:025:   error: undefined predicate `bar_m1/2'.
+method_impl.m:025:   error: undefined predicate `bar_m1'/2.
Index: tests/invalid/missing_det_decls.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/missing_det_decls.err_exp,v
retrieving revision 1.12
diff -u -b -r1.12 missing_det_decls.err_exp
--- tests/invalid/missing_det_decls.err_exp	27 Jul 2006 05:03:49 -0000	1.12
+++ tests/invalid/missing_det_decls.err_exp	5 Sep 2006 12:07:54 -0000
@@ -3,14 +3,18 @@
 missing_det_decls.m:008: Error: no determinism declaration for exported
 missing_det_decls.m:008:   predicate `missing_det_decls.exp2'/1.
 missing_det_decls.m:013: Error: no determinism declaration for local predicate
-missing_det_decls.m:013:   `missing_det_decls.loc1/0'.
+missing_det_decls.m:013:   `missing_det_decls.loc1'/0.
 missing_det_decls.m:013: (This is an error because you specified the
 missing_det_decls.m:013:   `--no-infer-det' options. Use the `--infer-det'
 missing_det_decls.m:013:   option if you want the compiler to automatically
 missing_det_decls.m:013:   infer the determinism of local predicates.)
 missing_det_decls.m:016: Error: no determinism declaration for local predicate
-missing_det_decls.m:016:   `missing_det_decls.loc2/1'.
+missing_det_decls.m:016:   `missing_det_decls.loc2'/1.
 missing_det_decls.m:016: (This is an error because you specified the
 missing_det_decls.m:016:   `--no-infer-det' options. Use the `--infer-det'
 missing_det_decls.m:016:   option if you want the compiler to automatically
 missing_det_decls.m:016:   infer the determinism of local predicates.)
+missing_det_decls.m:004: Error: no clauses for predicate `exp1'/0.
+missing_det_decls.m:007: Error: no clauses for predicate `exp2'/1.
+missing_det_decls.m:012: Error: no clauses for predicate `loc1'/0.
+missing_det_decls.m:015: Error: no clauses for predicate `loc2'/1.
Index: tests/invalid/missing_init_pred.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/missing_init_pred.err_exp,v
retrieving revision 1.2
diff -u -b -r1.2 missing_init_pred.err_exp
--- tests/invalid/missing_init_pred.err_exp	14 Sep 2005 05:26:48 -0000	1.2
+++ tests/invalid/missing_init_pred.err_exp	7 Sep 2006 04:21:16 -0000
@@ -1,2 +1,3 @@
-missing_init_pred.m:020: In clause for initialisation predicate for type missing_init_pred.t:
-missing_init_pred.m:020:   error: undefined predicate `missing_init_pred.init/1'.
+missing_init_pred.m:020: In clause for initialisation predicate for type `t':
+missing_init_pred.m:020:   error: undefined predicate
+missing_init_pred.m:020:   `missing_init_pred.init'/1.
Index: tests/invalid/missing_parent_import.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/missing_parent_import.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 missing_parent_import.err_exp
--- tests/invalid/missing_parent_import.err_exp	14 Sep 2005 05:26:48 -0000	1.3
+++ tests/invalid/missing_parent_import.err_exp	5 Sep 2006 12:06:51 -0000
@@ -1,8 +1,8 @@
-missing_parent_import.m:030: In clause for predicate `missing_parent_import.main/2':
-missing_parent_import.m:030:   error: undefined predicate `child.hello/2'
+missing_parent_import.m:030: In clause for predicate `main'/2:
+missing_parent_import.m:030:   error: undefined predicate `child.hello'/2
 missing_parent_import.m:030:   (the possible parent module `children' has not
 missing_parent_import.m:030:     been imported).
-missing_parent_import.m:033: In clause for predicate `missing_parent_import.main/2':
-missing_parent_import.m:033:   error: undefined predicate `child2.hello/2'
+missing_parent_import.m:033: In clause for predicate `main'/2:
+missing_parent_import.m:033:   error: undefined predicate `child2.hello'/2
 missing_parent_import.m:033:   (the possible parent module `children' has not
 missing_parent_import.m:033:     been imported).
Index: tests/invalid/mode_inf.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/mode_inf.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 mode_inf.err_exp
--- tests/invalid/mode_inf.err_exp	14 Jun 2006 08:14:54 -0000	1.7
+++ tests/invalid/mode_inf.err_exp	5 Sep 2006 12:07:55 -0000
@@ -1,10 +1,10 @@
 mode_inf.m:009: In clause for `p(out, out)':
-mode_inf.m:009:   in call to predicate `mode_inf.q/2':
+mode_inf.m:009:   in call to predicate `mode_inf.q'/2:
 mode_inf.m:009:   mode error: arguments `X, Y' have the following insts:
 mode_inf.m:009:     free,
 mode_inf.m:009:     free
 mode_inf.m:009:   which does not match any of the valid modes for the callee
-mode_inf.m:009:   (predicate `mode_inf.q/2')
+mode_inf.m:009:   (predicate `mode_inf.q'/2)
 mode_inf.m:009:   because of the following error.
 mode_inf.m:011: In clause for `q(out(not_reached), out(not_reached))':
 mode_inf.m:011:   in argument 2 of clause head:
Index: tests/invalid/modes_erroneous.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/modes_erroneous.err_exp,v
retrieving revision 1.10
diff -u -b -r1.10 modes_erroneous.err_exp
--- tests/invalid/modes_erroneous.err_exp	14 Jun 2006 08:14:54 -0000	1.10
+++ tests/invalid/modes_erroneous.err_exp	5 Sep 2006 12:07:56 -0000
@@ -4,7 +4,7 @@
 modes_erroneous.m:015:   In clause for `p((ground >> ground), (free >>
 modes_erroneous.m:015:   ground))':
 modes_erroneous.m:015:   in argument 1 of call to predicate
-modes_erroneous.m:015:   `modes_erroneous.p/2':
+modes_erroneous.m:015:   `modes_erroneous.p'/2:
 modes_erroneous.m:015:   mode error: variable `V_5' has instantiatedness
 modes_erroneous.m:015:   `free',
 modes_erroneous.m:015:   expected instantiatedness was `ground'.
Index: tests/invalid/mostly_uniq1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/mostly_uniq1.err_exp,v
retrieving revision 1.15
diff -u -b -r1.15 mostly_uniq1.err_exp
--- tests/invalid/mostly_uniq1.err_exp	14 Jun 2006 08:14:54 -0000	1.15
+++ tests/invalid/mostly_uniq1.err_exp	5 Sep 2006 12:07:56 -0000
@@ -1,8 +1,8 @@
-mostly_uniq1.m:005: In `my_main(di, uo)':
+mostly_uniq1.m:005: In `my_main'(di, uo):
 mostly_uniq1.m:005:   error: invalid determinism for a predicate with I/O state
 mostly_uniq1.m:005:   arguments.
 mostly_uniq1.m:018: In clause for `my_main(di, uo)':
-mostly_uniq1.m:018:   in argument 2 of call to predicate `io.write_int/3':
+mostly_uniq1.m:018:   in argument 2 of call to predicate `io.write_int'/3:
 mostly_uniq1.m:018:   mode error: variable `DCG_0' has instantiatedness
 mostly_uniq1.m:018:   `mostly_unique',
 mostly_uniq1.m:018:   expected instantiatedness was `unique'.
Index: tests/invalid/mostly_uniq2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/mostly_uniq2.err_exp,v
retrieving revision 1.13
diff -u -b -r1.13 mostly_uniq2.err_exp
--- tests/invalid/mostly_uniq2.err_exp	14 Jun 2006 08:14:54 -0000	1.13
+++ tests/invalid/mostly_uniq2.err_exp	5 Sep 2006 12:07:57 -0000
@@ -1,8 +1,8 @@
-mostly_uniq2.m:005: In `foo(di, uo)':
+mostly_uniq2.m:005: In `foo'(di, uo):
 mostly_uniq2.m:005:   error: invalid determinism for a predicate with I/O state
 mostly_uniq2.m:005:   arguments.
 mostly_uniq2.m:012: In clause for `foo(di, uo)':
-mostly_uniq2.m:012:   in argument 2 of call to predicate `io.write_int/3':
+mostly_uniq2.m:012:   in argument 2 of call to predicate `io.write_int'/3:
 mostly_uniq2.m:012:   mode error: variable `DCG_0' has instantiatedness
 mostly_uniq2.m:012:   `mostly_unique',
 mostly_uniq2.m:012:   expected instantiatedness was `unique'.
Index: tests/invalid/mpj1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/mpj1.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 mpj1.err_exp
--- tests/invalid/mpj1.err_exp	14 Jun 2006 08:14:54 -0000	1.3
+++ tests/invalid/mpj1.err_exp	6 Sep 2006 04:35:58 -0000
@@ -1,15 +1,13 @@
-mpj1.m:014: In clause for function `mpj1.g/1':
+mpj1.m:014: In clause for function `g'/1:
 mpj1.m:014:   in function result term of clause head:
 mpj1.m:014:   in argument 2 of functor `f/3':
 mpj1.m:014:   type error in unification of argument
 mpj1.m:014:   and constant `2'.
 mpj1.m:014:   argument has type `string',
 mpj1.m:014:   constant `2' has type `int'.
-	The partial type assignment was:
-	HeadVar__2_2: T2
-	L_3: T2
-	V_4: string
-	V_5: string
-	<= mpj1.coll(string, T2_2)
-
+mpj1.m:014:   The partial type assignment was:
+mpj1.m:014:     HeadVar__2_2: T2
+mpj1.m:014:     L_3: T2
+mpj1.m:014:     V_4: string
+mpj1.m:014:     V_5: string <= mpj1.coll(string, T2)
 mpj1.m:012: Inferred :- func f(E, E, T4) = T4 <= (mpj1.coll(E, T4)).
Index: tests/invalid/mpj4.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/mpj4.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 mpj4.err_exp
--- tests/invalid/mpj4.err_exp	14 Jun 2006 08:14:54 -0000	1.3
+++ tests/invalid/mpj4.err_exp	6 Sep 2006 04:36:37 -0000
@@ -1,13 +1,12 @@
-mpj4.m:020: In clause for function `mpj4.g/1':
+mpj4.m:020: In clause for function `g'/1:
 mpj4.m:020:   in function result term of clause head:
 mpj4.m:020:   in argument 2 of functor `f/3':
 mpj4.m:020:   type error in unification of argument
 mpj4.m:020:   and constant `"foo"'.
 mpj4.m:020:   argument has type `int',
 mpj4.m:020:   constant `"foo"' has type `string'.
-	The partial type assignment was:
-	HeadVar__2_2: (mpj4.intlist)
-	L_3: (mpj4.intlist)
-	V_4: int
-	V_5: int
-
+mpj4.m:020:   The partial type assignment was:
+mpj4.m:020:     HeadVar__2_2: (mpj4.intlist)
+mpj4.m:020:     L_3: (mpj4.intlist)
+mpj4.m:020:     V_4: int
+mpj4.m:020:     V_5: int
Index: tests/invalid/multimode_dcg.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/multimode_dcg.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 multimode_dcg.err_exp
--- tests/invalid/multimode_dcg.err_exp	14 Jun 2006 08:14:54 -0000	1.5
+++ tests/invalid/multimode_dcg.err_exp	5 Sep 2006 12:07:59 -0000
@@ -1,19 +1,19 @@
-multimode_dcg.m:027: In clause for predicate `multimode_dcg.test1/3':
+multimode_dcg.m:027: In clause for predicate `multimode_dcg.test1'/3:
 multimode_dcg.m:027:   syntax error: some but not all arguments have mode
 multimode_dcg.m:027:   annotations.
-multimode_dcg.m:029: In clause for predicate `multimode_dcg.test1/3':
+multimode_dcg.m:029: In clause for predicate `multimode_dcg.test1'/3:
 multimode_dcg.m:029:   syntax error: some but not all arguments have mode
 multimode_dcg.m:029:   annotations.
-multimode_dcg.m:037: In clause for predicate `multimode_dcg.test2/4':
+multimode_dcg.m:037: In clause for predicate `multimode_dcg.test2'/4:
 multimode_dcg.m:037:   syntax error: some but not all arguments have mode
 multimode_dcg.m:037:   annotations.
-multimode_dcg.m:039: In clause for predicate `multimode_dcg.test2/4':
+multimode_dcg.m:039: In clause for predicate `multimode_dcg.test2'/4:
 multimode_dcg.m:039:   syntax error: some but not all arguments have mode
 multimode_dcg.m:039:   annotations.
-multimode_dcg.m:041: In clause for predicate `multimode_dcg.test2/4':
+multimode_dcg.m:041: In clause for predicate `multimode_dcg.test2'/4:
 multimode_dcg.m:041:   syntax error: some but not all arguments have mode
 multimode_dcg.m:041:   annotations.
-multimode_dcg.m:043: In clause for predicate `multimode_dcg.test2/4':
+multimode_dcg.m:043: In clause for predicate `multimode_dcg.test2'/4:
 multimode_dcg.m:043:   syntax error: some but not all arguments have mode
 multimode_dcg.m:043:   annotations.
 multimode_dcg.m:029: In clause for `test1(out, di, uo)':
@@ -29,4 +29,3 @@
 multimode_dcg.m:043:   mode mismatch in disjunction.
 multimode_dcg.m:043:   `HeadVar__1' :: free, free, unique(0), unique(0).
 multimode_dcg.m:043:   `HeadVar__2' :: free, unique(0), free, unique(0).
-For more information, recompile with `-E'.
Index: tests/invalid/multimode_missing_impure.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/multimode_missing_impure.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 multimode_missing_impure.err_exp
--- tests/invalid/multimode_missing_impure.err_exp	14 Sep 2005 05:26:49 -0000	1.4
+++ tests/invalid/multimode_missing_impure.err_exp	5 Sep 2006 12:08:00 -0000
@@ -1,10 +1,10 @@
 multimode_missing_impure.m:025: In predicate
-multimode_missing_impure.m:025:   `multimode_missing_impure.test1/1':
+multimode_missing_impure.m:025:   `multimode_missing_impure.test1'/1:
 multimode_missing_impure.m:025:   purity error: predicate is impure.
 multimode_missing_impure.m:025:   It must be declared `impure' or promised
 multimode_missing_impure.m:025:   pure.
 multimode_missing_impure.m:034: In predicate
-multimode_missing_impure.m:034:   `multimode_missing_impure.test2/2':
+multimode_missing_impure.m:034:   `multimode_missing_impure.test2'/2:
 multimode_missing_impure.m:034:   purity error: predicate is impure.
 multimode_missing_impure.m:034:   It must be declared `impure' or promised
 multimode_missing_impure.m:034:   pure.
Index: tests/invalid/multimode_syntax.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/multimode_syntax.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 multimode_syntax.err_exp
--- tests/invalid/multimode_syntax.err_exp	27 Jul 2006 05:03:49 -0000	1.7
+++ tests/invalid/multimode_syntax.err_exp	5 Sep 2006 12:08:00 -0000
@@ -1,52 +1,54 @@
-multimode_syntax.m:013: Error: clause for predicate `multimode_syntax.::/2'
+multimode_syntax.m:013: Error: clause for predicate `multimode_syntax.::'/2
 multimode_syntax.m:013:   without preceding `pred' declaration.
-multimode_syntax.m:018: In clause for function `multimode_syntax.func1/1':
+multimode_syntax.m:018: In clause for function `multimode_syntax.func1'/1:
 multimode_syntax.m:018:   syntax error: some but not all arguments have mode
 multimode_syntax.m:018:   annotations.
-multimode_syntax.m:019: In clause for function `multimode_syntax.func1/1':
+multimode_syntax.m:019: In clause for function `multimode_syntax.func1'/1:
 multimode_syntax.m:019:   syntax error: some but not all arguments have mode
 multimode_syntax.m:019:   annotations.
-multimode_syntax.m:025: In clause for function `multimode_syntax.func2/2':
+multimode_syntax.m:025: In clause for function `multimode_syntax.func2'/2:
 multimode_syntax.m:025:   error: mode annotation specifies undeclared mode
 multimode_syntax.m:025:   `func2(in, out) = out'
-multimode_syntax.m:025:   of function `multimode_syntax.func2/2'.
+multimode_syntax.m:025:   of function `multimode_syntax.func2'/2.
 	The declared modes for this function are the following:
 		:- mode func2(in, in) = out is det.
-multimode_syntax.m:027: In clause for function `multimode_syntax.func2/2':
+multimode_syntax.m:027: In clause for function `multimode_syntax.func2'/2:
 multimode_syntax.m:027:   error: mode annotation specifies undeclared mode
 multimode_syntax.m:027:   `func2(out, in) = out'
-multimode_syntax.m:027:   of function `multimode_syntax.func2/2'.
+multimode_syntax.m:027:   of function `multimode_syntax.func2'/2.
 	The declared modes for this function are the following:
 		:- mode func2(in, in) = out is det.
-multimode_syntax.m:029: In clause for function `multimode_syntax.func2/2':
+multimode_syntax.m:029: In clause for function `multimode_syntax.func2'/2:
 multimode_syntax.m:029:   error: mode annotation specifies undeclared mode
 multimode_syntax.m:029:   `func2(out, out) = out'
-multimode_syntax.m:029:   of function `multimode_syntax.func2/2'.
+multimode_syntax.m:029:   of function `multimode_syntax.func2'/2.
 	The declared modes for this function are the following:
 		:- mode func2(in, in) = out is det.
-multimode_syntax.m:033: In clause for function `multimode_syntax.func2b/2':
+multimode_syntax.m:033: In clause for function `multimode_syntax.func2b'/2:
 multimode_syntax.m:033:   error: mode annotation specifies undeclared mode
 multimode_syntax.m:033:   `func2b(in, out) = out'
-multimode_syntax.m:033:   of function `multimode_syntax.func2b/2'.
+multimode_syntax.m:033:   of function `multimode_syntax.func2b'/2.
 	The declared modes for this function are the following:
 		:- mode func2b(in, in) = out is det.
-multimode_syntax.m:037: In clause for predicate `multimode_syntax.pred2b/2':
+multimode_syntax.m:037: In clause for predicate `multimode_syntax.pred2b'/2:
 multimode_syntax.m:037:   error: mode annotation specifies undeclared mode
 multimode_syntax.m:037:   `pred2b(in, out)'
-multimode_syntax.m:037:   of predicate `multimode_syntax.pred2b/2'.
+multimode_syntax.m:037:   of predicate `multimode_syntax.pred2b'/2.
 multimode_syntax.m:037:   (There are no declared modes for this predicate.)
-multimode_syntax.m:045: In clause for predicate `multimode_syntax.test2/2':
+multimode_syntax.m:045: In clause for predicate `multimode_syntax.test2'/2:
 multimode_syntax.m:045:   syntax error: some but not all arguments have mode
 multimode_syntax.m:045:   annotations.
-multimode_syntax.m:047: In clause for predicate `multimode_syntax.test2/2':
+multimode_syntax.m:047: In clause for predicate `multimode_syntax.test2'/2:
 multimode_syntax.m:047:   syntax error: some but not all arguments have mode
 multimode_syntax.m:047:   annotations.
-multimode_syntax.m:013: In clause for predicate `multimode_syntax.::/2':
+multimode_syntax.m:011: Error: no clauses for function `func0'/0.
+multimode_syntax.m:013: In clause for predicate `::'/2:
 multimode_syntax.m:013:   in argument 1 of clause head:
-multimode_syntax.m:013:   error: the language construct =/2 should be
-multimode_syntax.m:013:   used as a goal, not as an expression.
-multimode_syntax.m:013:   If you are trying to use a goal as a boolean function,
-multimode_syntax.m:013:   you should write `if <goal> then yes else no' instead.
-multimode_syntax.m:013: In clause for predicate `multimode_syntax.::/2':
+multimode_syntax.m:013:   error: the language construct `='/2 should be used as
+multimode_syntax.m:013:   a goal, not as an expression.
+multimode_syntax.m:013:   If you are trying to use a goal as a boolean
+multimode_syntax.m:013:   function, you should write `if <goal> then yes else
+multimode_syntax.m:013:   no' instead.
+multimode_syntax.m:013: In clause for predicate `::'/2:
 multimode_syntax.m:013:   in argument 2 of clause head:
 multimode_syntax.m:013:   error: undefined symbol `out/0'.
Index: tests/invalid/multisoln_func.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/multisoln_func.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 multisoln_func.err_exp
--- tests/invalid/multisoln_func.err_exp	14 Jun 2006 07:42:55 -0000	1.7
+++ tests/invalid/multisoln_func.err_exp	6 Sep 2006 14:42:54 -0000
@@ -1,7 +1,7 @@
 multisoln_func.m:026: Inferred :- func test2 = int.
 multisoln_func.m:030: Inferred :- func test3(int) = int.
 multisoln_func.m:034: Inferred :- func test3b(int) = int.
-multisoln_func.m:013: Error: invalid determinism for `f(in) = out':
+multisoln_func.m:013: Error: invalid determinism for `f'(in) = out:
 multisoln_func.m:013:   the primary mode of a function cannot be `cc_multi'.
 multisoln_func.m:013:   In Mercury, a function is supposed to be a true
 multisoln_func.m:013:   mathematical function of its arguments; that is, the
@@ -11,7 +11,7 @@
 multisoln_func.m:013:   arguments would break referential transparency.) Most
 multisoln_func.m:013:   likely, this procedure should be a predicate, not a
 multisoln_func.m:013:   function.
-multisoln_func.m:019: Error: invalid determinism for `test = out':
+multisoln_func.m:019: Error: invalid determinism for `test' = out:
 multisoln_func.m:019:   the primary mode of a function cannot be `cc_multi'.
 multisoln_func.m:019:   In Mercury, a function is supposed to be a true
 multisoln_func.m:019:   mathematical function of its arguments; that is, the
@@ -21,7 +21,7 @@
 multisoln_func.m:019:   arguments would break referential transparency.) Most
 multisoln_func.m:019:   likely, this procedure should be a predicate, not a
 multisoln_func.m:019:   function.
-multisoln_func.m:026: Error: invalid determinism for `test2 = out':
+multisoln_func.m:026: Error: invalid determinism for `test2' = out:
 multisoln_func.m:026:   the primary mode of a function cannot be `multi'.
 multisoln_func.m:026:   In Mercury, a function is supposed to be a true
 multisoln_func.m:026:   mathematical function of its arguments; that is, the
@@ -31,7 +31,7 @@
 multisoln_func.m:026:   arguments would break referential transparency.) Most
 multisoln_func.m:026:   likely, this procedure should be a predicate, not a
 multisoln_func.m:026:   function.
-multisoln_func.m:030: Error: invalid determinism for `test3(in) = out':
+multisoln_func.m:030: Error: invalid determinism for `test3'(in) = out:
 multisoln_func.m:030:   the primary mode of a function cannot be `nondet'.
 multisoln_func.m:030:   In Mercury, a function is supposed to be a true
 multisoln_func.m:030:   mathematical function of its arguments; that is, the
@@ -41,7 +41,7 @@
 multisoln_func.m:030:   arguments would break referential transparency.) Most
 multisoln_func.m:030:   likely, this procedure should be a predicate, not a
 multisoln_func.m:030:   function.
-multisoln_func.m:034: Error: invalid determinism for `test3b(in) = out':
+multisoln_func.m:034: Error: invalid determinism for `test3b'(in) = out:
 multisoln_func.m:034:   the primary mode of a function cannot be `cc_nondet'.
 multisoln_func.m:034:   In Mercury, a function is supposed to be a true
 multisoln_func.m:034:   mathematical function of its arguments; that is, the
Index: tests/invalid/not_a_switch.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/not_a_switch.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 not_a_switch.err_exp
--- tests/invalid/not_a_switch.err_exp	29 Mar 2006 08:08:06 -0000	1.5
+++ tests/invalid/not_a_switch.err_exp	5 Sep 2006 12:08:03 -0000
@@ -1,7 +1,7 @@
-not_a_switch.m:009: In `not_a_switch(in, out)':
+not_a_switch.m:009: In `not_a_switch'(in, out):
 not_a_switch.m:009:   error: determinism declaration not satisfied.
 not_a_switch.m:009:   Declared `det', inferred `nondet'.
+not_a_switch.m:013:   Disjunction has multiple clauses with solutions.
 not_a_switch.m:015:   Unification of `A' and `maybe.yes(Int2)' can fail.
 not_a_switch.m:016:   In argument 1 of clause head:
 not_a_switch.m:016:   unification of `HeadVar__1' and `maybe.no' can fail.
-not_a_switch.m:013:   Disjunction has multiple clauses with solutions.
Index: tests/invalid/not_in_interface.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/not_in_interface.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 not_in_interface.err_exp
--- tests/invalid/not_in_interface.err_exp	15 Sep 2005 07:38:47 -0000	1.3
+++ tests/invalid/not_in_interface.err_exp	5 Sep 2006 12:08:04 -0000
@@ -2,5 +2,5 @@
 not_in_interface.m:013: Error: `mutable' declaration in module interface.
 not_in_interface.m:015: Error: `initialise' declaration in module interface.
 not_in_interface.m:019: Error: `pragma' declaration in module interface.
-not_in_interface.m:022: Error: clause for predicate `foo/2' in module
+not_in_interface.m:022: Error: clause for predicate `foo'/2 in module
 not_in_interface.m:022:   interface.
Index: tests/invalid/nullary_ho_func_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/nullary_ho_func_error.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 nullary_ho_func_error.err_exp
--- tests/invalid/nullary_ho_func_error.err_exp	14 Jun 2006 08:14:54 -0000	1.5
+++ tests/invalid/nullary_ho_func_error.err_exp	6 Sep 2006 14:42:56 -0000
@@ -1,15 +1,14 @@
-nullary_ho_func_error.m:022: In clause for predicate `nullary_ho_func_error.main/2':
-nullary_ho_func_error.m:022:   in argument 1 of call to predicate `print/3':
+nullary_ho_func_error.m:022: In clause for predicate `main'/2:
+nullary_ho_func_error.m:022:   in argument 1 of call to predicate `print'/3:
 nullary_ho_func_error.m:022:   in argument 1 of functor `apply_nullary_func/1':
 nullary_ho_func_error.m:022:   type error in unification of argument
 nullary_ho_func_error.m:022:   and constant `pi'.
 nullary_ho_func_error.m:022:   argument has type `((func) = T)',
 nullary_ho_func_error.m:022:   constant `pi' has type `float'.
-	The partial type assignment was:
-	DCG_0_3: (io.state)
-	DCG_1_4: (io.state)
-	DCG_3_6: (io.state)
-	V_7: string
-	V_8: T
-	V_9: ((func) = T)
-
+nullary_ho_func_error.m:022:   The partial type assignment was:
+nullary_ho_func_error.m:022:     DCG_0_3: (io.state)
+nullary_ho_func_error.m:022:     DCG_1_4: (io.state)
+nullary_ho_func_error.m:022:     DCG_3_6: (io.state)
+nullary_ho_func_error.m:022:     V_7: string
+nullary_ho_func_error.m:022:     V_8: T
+nullary_ho_func_error.m:022:     V_9: ((func) = T)
Index: tests/invalid/occurs.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/occurs.err_exp,v
retrieving revision 1.11
diff -u -b -r1.11 occurs.err_exp
--- tests/invalid/occurs.err_exp	14 Jun 2006 08:14:54 -0000	1.11
+++ tests/invalid/occurs.err_exp	5 Sep 2006 12:08:05 -0000
@@ -1,5 +1,5 @@
 occurs.m:001: Warning: interface for module `occurs' does not export anything.
-occurs.m:008: In clause for predicate `occurs.p/0':
+occurs.m:008: In clause for predicate `occurs.p'/0:
 occurs.m:008:   warning: variable `X' occurs only once in this scope.
 occurs.m:008: In clause for `p':
 occurs.m:008:   mode error in unification of `X' and `occurs.f(X)'.
Index: tests/invalid/one_member.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/one_member.err_exp,v
retrieving revision 1.2
diff -u -b -r1.2 one_member.err_exp
--- tests/invalid/one_member.err_exp	14 Jun 2006 08:14:55 -0000	1.2
+++ tests/invalid/one_member.err_exp	5 Sep 2006 12:08:05 -0000
@@ -1,10 +1,10 @@
 one_member.m:044: Error: this `arbitrary' scope is not nested inside a
 one_member.m:044:   `promise_equivalent_solution_sets' scope.
+one_member.m:051: Error: the `arbitrary' goal lists an extra variable: Tree.
 one_member.m:051: Error: this `arbitrary' scope and the
 one_member.m:051:   `promise_equivalent_solution_sets' scope it is nested
 one_member.m:051:   inside overlap on the variable Item.
 one_member.m:050:   This is the outer `promise_equivalent_solution_sets' scope.
-one_member.m:051: Error: the `arbitrary' goal lists an extra variable: Tree.
 one_member.m:052: Error: unification for non-canonical type
 one_member.m:052:   `one_member.set_ctree234/1' occurs in a context which
 one_member.m:052:   requires all solutions.
@@ -21,6 +21,6 @@
 one_member.m:061: Error: `promise_equivalent_solution_sets' scope is nested
 one_member.m:061:   inside another.
 one_member.m:060:   This is the outer `promise_equivalent_solution_sets' scope.
-one_member.m:047: In `one_member2(in, out)':
+one_member.m:047: In `one_member2'(in, out):
 one_member.m:047:   warning: determinism declaration could be tighter.
 one_member.m:047:   Declared `nondet', inferred `semidet'.
Index: tests/invalid/overloading.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/overloading.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 overloading.err_exp
--- tests/invalid/overloading.err_exp	15 Jun 2006 04:32:05 -0000	1.7
+++ tests/invalid/overloading.err_exp	5 Sep 2006 12:08:06 -0000
@@ -1,13 +1,30 @@
-overloading.m:050: In clause for predicate `overloading.p/4':
+overloading.m:050: In clause for predicate `p'/4:
 overloading.m:050:   in unification of variable `OptInfo'
-overloading.m:050:   and term `opt_info(MustHaveOwnSlot, EverOnStack, CurIntervalId, V_22, Counter1, StartMap0, EndMap0, VarsMap0, SuccMap0)':
+overloading.m:050:   and term
+overloading.m:050:   `opt_info(MustHaveOwnSlot, EverOnStack, CurIntervalId, V_22, Counter1, StartMap0, EndMap0, VarsMap0, SuccMap0)':
 overloading.m:050:   type error in argument(s) of functor `opt_info/9'.
 overloading.m:050:   variable `OptInfo' has type `(overloading.opt_info)',
 overloading.m:050:   functor `opt_info/9' has type 
-overloading.m:050:   `opt_info((set.set((term.var((term.generic))))), (set.set((term.var((term.generic))))), (tree234.tree234((term.var((term.generic))), (tree234.tree234((overloading.goal_path), string)))), (overloading.interval_id), (counter.counter), (tree234.tree234((overloading.interval_id), (overloading.anchor))), (tree234.tree234((overloading.interval_id), (overloading.anchor))), (tree234.tree234((overloading.interval_id), (set.set((term.var((term.generic))))))), (tree234.tree234((overloading.interval_id), (list.list((overloading.interval_id)))))): (overloading.opt_info)',
-overloading.m:050:   variable `MustHaveOwnSlot' has type `(set.set((term.var((term.generic)))))',
-overloading.m:050:   variable `EverOnStack' has type `(set.set((term.var((term.generic)))))',
-overloading.m:050:   variable `CurIntervalId' has type `(overloading.interval_id)',
+overloading.m:050:   `opt_info((set.set((term.var((term.generic))))),
+overloading.m:050:   (set.set((term.var((term.generic))))),
+overloading.m:050:   (tree234.tree234((term.var((term.generic))),
+overloading.m:050:   (tree234.tree234((overloading.goal_path), string)))),
+overloading.m:050:   (overloading.interval_id), (counter.counter),
+overloading.m:050:   (tree234.tree234((overloading.interval_id),
+overloading.m:050:   (overloading.anchor))),
+overloading.m:050:   (tree234.tree234((overloading.interval_id),
+overloading.m:050:   (overloading.anchor))),
+overloading.m:050:   (tree234.tree234((overloading.interval_id),
+overloading.m:050:   (set.set((term.var((term.generic))))))),
+overloading.m:050:   (tree234.tree234((overloading.interval_id),
+overloading.m:050:   (list.list((overloading.interval_id)))))):
+overloading.m:050:   (overloading.opt_info)',
+overloading.m:050:   variable `MustHaveOwnSlot' has type
+overloading.m:050:   `(set.set((term.var((term.generic)))))',
+overloading.m:050:   variable `EverOnStack' has type
+overloading.m:050:   `(set.set((term.var((term.generic)))))',
+overloading.m:050:   variable `CurIntervalId' has type
+overloading.m:050:   `(overloading.interval_id)',
 overloading.m:050:   argument has type `'<any>'',
 overloading.m:050:   variable `Counter1' has type `(counter.counter)',
 overloading.m:050:   variable `StartMap0' has overloaded type {
@@ -15,12 +32,16 @@
 overloading.m:050:     (tree234.tree234(K, V))
 overloading.m:050:   },
 overloading.m:050:   variable `EndMap0' has overloaded type {
-overloading.m:050:     (pred (tree234.tree234((overloading.interval_id), (overloading.anchor)))),
-overloading.m:050:     (tree234.tree234((overloading.interval_id), (overloading.anchor)))
+overloading.m:050:       (pred (tree234.tree234((overloading.interval_id),
+overloading.m:050:       (overloading.anchor)))),
+overloading.m:050:       (tree234.tree234((overloading.interval_id),
+overloading.m:050:       (overloading.anchor)))
 overloading.m:050:   },
 overloading.m:050:   variable `VarsMap0' has overloaded type {
-overloading.m:050:     (pred (tree234.tree234((overloading.interval_id), (set.set((term.var((term.generic)))))))),
-overloading.m:050:     (tree234.tree234((overloading.interval_id), (set.set((term.var((term.generic)))))))
+overloading.m:050:       (pred (tree234.tree234((overloading.interval_id),
+overloading.m:050:       (set.set((term.var((term.generic)))))))),
+overloading.m:050:       (tree234.tree234((overloading.interval_id),
+overloading.m:050:       (set.set((term.var((term.generic)))))))
 overloading.m:050:   },
 overloading.m:050:   variable `SuccMap0' has overloaded type {
 overloading.m:050:     (pred (tree234.tree234(V_V_1, V_V_2))),
Index: tests/invalid/partial_implied_mode.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/partial_implied_mode.err_exp,v
retrieving revision 1.11
diff -u -b -r1.11 partial_implied_mode.err_exp
--- tests/invalid/partial_implied_mode.err_exp	14 Jun 2006 08:14:55 -0000	1.11
+++ tests/invalid/partial_implied_mode.err_exp	5 Sep 2006 12:06:52 -0000
@@ -22,4 +22,3 @@
 partial_implied_mode.m:033:     ground,
 partial_implied_mode.m:033:     free
 partial_implied_mode.m:033:   )'.
-For more information, recompile with `-E'.
Index: tests/invalid/pragma_c_code_dup_var.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/pragma_c_code_dup_var.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 pragma_c_code_dup_var.err_exp
--- tests/invalid/pragma_c_code_dup_var.err_exp	27 Jul 2006 05:03:49 -0000	1.9
+++ tests/invalid/pragma_c_code_dup_var.err_exp	5 Sep 2006 12:08:07 -0000
@@ -1,4 +1,5 @@
 pragma_c_code_dup_var.m:019: In `:- pragma foreign_proc' declaration for
-pragma_c_code_dup_var.m:019:   function `pragma_c_code_dup_var.bread_impl/6':
+pragma_c_code_dup_var.m:019:   function `pragma_c_code_dup_var.bread_impl'/6:
 pragma_c_code_dup_var.m:019:   error: variable `Buf' occurs multiple times in
 pragma_c_code_dup_var.m:019:   the argument list.
+pragma_c_code_dup_var.m:014: Error: no clauses for function `bread_impl'/7.
Index: tests/invalid/pragma_c_code_no_det.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/pragma_c_code_no_det.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 pragma_c_code_no_det.err_exp
--- tests/invalid/pragma_c_code_no_det.err_exp	14 Sep 2005 05:26:50 -0000	1.3
+++ tests/invalid/pragma_c_code_no_det.err_exp	5 Sep 2006 12:08:08 -0000
@@ -1,7 +1,7 @@
-pragma_c_code_no_det.m:012: In `c_code(out)':
+pragma_c_code_no_det.m:012: In `c_code'(out):
 pragma_c_code_no_det.m:012:   error: `:- pragma c_code(...)' for a procedure
 pragma_c_code_no_det.m:012:   without a determinism declaration.
-pragma_c_code_no_det.m:005: In `test(out)':
+pragma_c_code_no_det.m:005: In `test'(out):
 pragma_c_code_no_det.m:005:   warning: determinism declaration could be
 pragma_c_code_no_det.m:005:   tighter.
 pragma_c_code_no_det.m:005:   Declared `det', inferred `erroneous'.
Index: tests/invalid/prog_io_erroneous.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/prog_io_erroneous.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 prog_io_erroneous.err_exp
--- tests/invalid/prog_io_erroneous.err_exp	14 Jun 2006 08:14:55 -0000	1.9
+++ tests/invalid/prog_io_erroneous.err_exp	5 Sep 2006 12:08:09 -0000
@@ -5,4 +5,4 @@
 prog_io_erroneous.m:001:   `:- import_module' in its interface section(s). This
 prog_io_erroneous.m:001:   would normally be a `:- pred', `:- func', `:- type',
 prog_io_erroneous.m:001:   `:- inst' or `:- mode' declaration.
-prog_io_erroneous.m:012: Error: no clauses for predicate `q/2'.
+prog_io_erroneous.m:012: Error: no clauses for predicate `q'/2.
Index: tests/invalid/promise_equivalent_clauses.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/promise_equivalent_clauses.err_exp,v
retrieving revision 1.1
diff -u -b -r1.1 promise_equivalent_clauses.err_exp
--- tests/invalid/promise_equivalent_clauses.err_exp	8 Mar 2006 02:25:43 -0000	1.1
+++ tests/invalid/promise_equivalent_clauses.err_exp	5 Sep 2006 12:08:10 -0000
@@ -1,5 +1,5 @@
 promise_equivalent_clauses.m:033: In predicate
-promise_equivalent_clauses.m:033:   `promise_equivalent_clauses.rsort/2':
+promise_equivalent_clauses.m:033:   `promise_equivalent_clauses.rsort'/2:
 promise_equivalent_clauses.m:033:   purity error: predicate is impure.
 promise_equivalent_clauses.m:033:   It must be declared `impure' or promised
 promise_equivalent_clauses.m:033:   pure.
Index: tests/invalid/qual_basic_test2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/qual_basic_test2.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 qual_basic_test2.err_exp
--- tests/invalid/qual_basic_test2.err_exp	14 Sep 2005 05:26:50 -0000	1.3
+++ tests/invalid/qual_basic_test2.err_exp	5 Sep 2006 12:08:11 -0000
@@ -1,2 +1,2 @@
-qual_basic_test2.m:014: In clause for predicate `qual_basic_test2.main/2':
-qual_basic_test2.m:014:   error: undefined predicate `io.io__write_string/3'.
+qual_basic_test2.m:014: In clause for predicate `main'/2:
+qual_basic_test2.m:014:   error: undefined predicate `io.io__write_string'/3.
Index: tests/invalid/qualified_cons_id2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/qualified_cons_id2.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 qualified_cons_id2.err_exp
--- tests/invalid/qualified_cons_id2.err_exp	18 Jan 2006 03:08:28 -0000	1.9
+++ tests/invalid/qualified_cons_id2.err_exp	5 Sep 2006 12:08:12 -0000
@@ -1,8 +1,9 @@
 qualified_cons_id2.m:015: In mode declarations for predicate
-qualified_cons_id2.m:015:   `qualified_cons_id2.test/2':
+qualified_cons_id2.m:015:   `qualified_cons_id2.test'/2:
 qualified_cons_id2.m:015:   error: duplicate mode declaration.
 qualified_cons_id2.m:016:   Here is the conflicting mode declaration.
-qualified_cons_id2.m:015: In `test(in(bound(qualified_cons_id2.yes(ground))),
-qualified_cons_id2.m:015:   out)':
+qualified_cons_id2.m:015: In `test'(in(bound(qualified_cons_id2.yes(ground))),
+qualified_cons_id2.m:015:   out):
 qualified_cons_id2.m:015:   error: determinism declaration not satisfied.
 qualified_cons_id2.m:015:   Declared `det', inferred `failure'.
+For more information, recompile with `-E'.
Index: tests/invalid/quant_constraint_1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/quant_constraint_1.err_exp,v
retrieving revision 1.2
diff -u -b -r1.2 quant_constraint_1.err_exp
--- tests/invalid/quant_constraint_1.err_exp	14 Sep 2005 05:26:50 -0000	1.2
+++ tests/invalid/quant_constraint_1.err_exp	5 Sep 2006 12:08:12 -0000
@@ -1,6 +1,6 @@
-quant_constraint_1.m:015: In declaration of predicate `quant_constraint_1.p/2':
+quant_constraint_1.m:015: In declaration of predicate `quant_constraint_1.p'/2:
 quant_constraint_1.m:015:   type variable T2 is universally constrained, but is
 quant_constraint_1.m:015:   existentially quantified.
-quant_constraint_1.m:015: In declaration of predicate `quant_constraint_1.p/2':
+quant_constraint_1.m:015: In declaration of predicate `quant_constraint_1.p'/2:
 quant_constraint_1.m:015:   type variable T1 is existentially constrained, but
 quant_constraint_1.m:015:   is universally quantified.
Index: tests/invalid/quant_constraint_2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/quant_constraint_2.err_exp,v
retrieving revision 1.2
diff -u -b -r1.2 quant_constraint_2.err_exp
--- tests/invalid/quant_constraint_2.err_exp	14 Sep 2005 05:26:50 -0000	1.2
+++ tests/invalid/quant_constraint_2.err_exp	5 Sep 2006 12:08:13 -0000
@@ -1,3 +1,3 @@
-quant_constraint_2.m:012: In declaration of function `quant_constraint_2.q/0':
+quant_constraint_2.m:012: In declaration of function `quant_constraint_2.q'/0:
 quant_constraint_2.m:012:   type variable T is universally constrained, but is
 quant_constraint_2.m:012:   existentially quantified.
Index: tests/invalid/record_syntax_errors.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/record_syntax_errors.err_exp,v
retrieving revision 1.15
diff -u -b -r1.15 record_syntax_errors.err_exp
--- tests/invalid/record_syntax_errors.err_exp	27 Jul 2006 05:03:49 -0000	1.15
+++ tests/invalid/record_syntax_errors.err_exp	5 Sep 2006 12:08:14 -0000
@@ -1,5 +1,5 @@
 record_syntax_errors.m:023: Error: mode declaration for function
-record_syntax_errors.m:023:   `record_syntax_errors.field8/1'
+record_syntax_errors.m:023:   `record_syntax_errors.field8'/1
 record_syntax_errors.m:023:   without preceding `func' declaration.
 record_syntax_errors.m:028: In DCG field update goal:
 record_syntax_errors.m:028:   error: expected field name at term `Field'.
@@ -7,39 +7,44 @@
 record_syntax_errors.m:031:   `^ field1 ^ ... ^ fieldN := Field' in DCG field
 record_syntax_errors.m:031:   access goal.
 record_syntax_errors.m:048: Error: clause for predicate
-record_syntax_errors.m:048:   `record_syntax_errors.term_type_error/1'
+record_syntax_errors.m:048:   `record_syntax_errors.term_type_error'/1
 record_syntax_errors.m:048:   without preceding `pred' declaration.
 record_syntax_errors.m:054: In declaration of function
-record_syntax_errors.m:054:   `record_syntax_errors.field4/1':
+record_syntax_errors.m:054:   `record_syntax_errors.field4'/1:
 record_syntax_errors.m:054:   error: a field access function for an exported
 record_syntax_errors.m:054:   field must also be exported.
 record_syntax_errors.m:057: Error: clause for automatically generated field
-record_syntax_errors.m:057:   access function `record_syntax_errors.field4/1'.
+record_syntax_errors.m:057:   access function `record_syntax_errors.field4'/1.
 record_syntax_errors.m:057:   Clauses for field access functions are
 record_syntax_errors.m:057:   automatically generated by the compiler. To
 record_syntax_errors.m:057:   supply your own definition for a field access
 record_syntax_errors.m:057:   function, for example to check the input to a
 record_syntax_errors.m:057:   field update, give the field of the constructor a
 record_syntax_errors.m:057:   different name.
-record_syntax_errors.m:042: In clause for predicate `record_syntax_errors.construct_exist_cons/1':
+record_syntax_errors.m:014: Error: no clauses for predicate `dcg_syntax'/2.
+record_syntax_errors.m:016: Error: no clauses for predicate `dcg_syntax_2'/2.
+record_syntax_errors.m:042: In clause for predicate `construct_exist_cons'/1:
 record_syntax_errors.m:042:   error: undefined symbol `field2 :=/2'.
 record_syntax_errors.m:005:   Field `field2' cannot be updated because the
 record_syntax_errors.m:005:   existentially quantified type variable `T' occurs
 record_syntax_errors.m:005:   in the types of field `field2' and some other
 record_syntax_errors.m:005:   field in definition of constructor
 record_syntax_errors.m:005:   `record_syntax_errors.exist_cons/3'.
-record_syntax_errors.m:046: In clause for predicate `record_syntax_errors.arg_type_error/1':
+record_syntax_errors.m:046: In clause for predicate `arg_type_error'/1:
 record_syntax_errors.m:046:   in argument 2 of functor `field6 :=/2':
 record_syntax_errors.m:046:   in unification of argument
 record_syntax_errors.m:046:   and term `'field7 :='(V_10, V_9)':
-record_syntax_errors.m:046:   type error in argument(s) of functor `field7 :=/2'.
+record_syntax_errors.m:046:   type error in argument(s) of functor
+record_syntax_errors.m:046:   `field7 :=/2'.
 record_syntax_errors.m:046:   Argument 2 has type `string',
 record_syntax_errors.m:046:   expected type was `int'.
-record_syntax_errors.m:050: In clause for predicate `record_syntax_errors.term_type_error/1':
+record_syntax_errors.m:050: In clause for predicate `term_type_error'/1:
 record_syntax_errors.m:050:   in argument 2 of functor `field6 :=/2':
 record_syntax_errors.m:050:   in unification of argument
 record_syntax_errors.m:050:   and term `'field4 :='(V_10, V_9)':
-record_syntax_errors.m:050:   type error in argument(s) of functor `field4 :=/2'.
-record_syntax_errors.m:050:   Argument 1 has type `(record_syntax_errors.cons2)',
+record_syntax_errors.m:050:   type error in argument(s) of functor
+record_syntax_errors.m:050:   `field4 :=/2'.
+record_syntax_errors.m:050:   Argument 1 has type
+record_syntax_errors.m:050:   `(record_syntax_errors.cons2)',
 record_syntax_errors.m:050:   expected type was `(record_syntax_errors.cons)'.
 record_syntax_errors.m:023: Inferred :- func field8((record_syntax_errors.cons2)) = int.
Index: tests/invalid/reserve_tag.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/reserve_tag.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 reserve_tag.err_exp
--- tests/invalid/reserve_tag.err_exp	14 Sep 2005 05:26:50 -0000	1.3
+++ tests/invalid/reserve_tag.err_exp	6 Sep 2006 14:43:27 -0000
@@ -1,17 +1,17 @@
 reserve_tag.m:023: Error: expected type name/arity for `pragma reserve_tag' declaration: list__list / 1.
 reserve_tag.m:021: In `pragma reserve_tag' declaration for
-reserve_tag.m:021:   `reserve_tag.undefined_type/1':
-reserve_tag.m:021:   error: undefined type `reserve_tag.undefined_type/1'.
+reserve_tag.m:021:   `reserve_tag.undefined_type'/1:
+reserve_tag.m:021:   error: undefined type `reserve_tag.undefined_type'/1.
 reserve_tag.m:024: In `pragma reserve_tag' declaration for
-reserve_tag.m:024:   `reserve_tag.list/1':
-reserve_tag.m:024:   error: undefined type `reserve_tag.list/1'.
+reserve_tag.m:024:   `reserve_tag.list'/1:
+reserve_tag.m:024:   error: undefined type `reserve_tag.list'/1.
 reserve_tag.m:025: In `pragma reserve_tag' declaration for
-reserve_tag.m:025:   `reserve_tag.exported_type/0':
+reserve_tag.m:025:   `reserve_tag.exported_type'/0:
 reserve_tag.m:025:   error: `reserve_tag' declaration must have the same
 reserve_tag.m:025:   visibility as the type definition.
 reserve_tag.m:032: In `pragma reserve_tag' declaration for
-reserve_tag.m:032:   `reserve_tag.invalid_arity/1':
-reserve_tag.m:032:   error: undefined type `reserve_tag.invalid_arity/1'.
-reserve_tag.m:044: In `pragma reserve_tag' declaration for `reserve_tag.foo/0':
+reserve_tag.m:032:   `reserve_tag.invalid_arity'/1:
+reserve_tag.m:032:   error: undefined type `reserve_tag.invalid_arity'/1.
+reserve_tag.m:044: In `pragma reserve_tag' declaration for `reserve_tag.foo'/0:
 reserve_tag.m:044:   warning: multiple `pragma reserved_tag' declarations for
 reserve_tag.m:044:   the same type.
Index: tests/invalid/some.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/some.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 some.err_exp
--- tests/invalid/some.err_exp	27 Jul 2006 05:03:49 -0000	1.7
+++ tests/invalid/some.err_exp	5 Sep 2006 12:08:15 -0000
@@ -1,3 +1,5 @@
 some.m:006: Error: unrecognized declaration: some junk pred p2((int :: in)) is semidet.
 some.m:012: Error: in first argument of some: expected list of variables and/or state variables: junk.
 some.m:013: Error: in first argument of some: expected list of variables and/or state variables: junk.
+some.m:005: Error: no clauses for predicate `p1'/1.
+some.m:007: Error: no clauses for predicate `p3'/1.
Index: tests/invalid/some.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/some.m,v
retrieving revision 1.1
diff -u -b -r1.1 some.m
--- tests/invalid/some.m	29 Oct 1998 14:59:13 -0000	1.1
+++ tests/invalid/some.m	5 Sep 2006 14:53:51 -0000
@@ -11,4 +11,3 @@
 
 p1(X) :- some junk p3(X).
 p3(X) :- ( some junk X > 0 -> X = 42 ; X = -42 ).
-
Index: tests/invalid/specified.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/specified.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 specified.err_exp
--- tests/invalid/specified.err_exp	8 Jun 2006 08:20:11 -0000	1.3
+++ tests/invalid/specified.err_exp	5 Sep 2006 12:08:15 -0000
@@ -1,15 +1,15 @@
 specified.m:155: Error: expected argument tabling method: implied.
 specified.m:138: Error in `pragma memo' declaration for predicate
-specified.m:138:   `specified.ap_lp_fib/3':
+specified.m:138:   `specified.ap_lp_fib'/3:
 specified.m:138:   argument 3: argument tabling method `addr' is not compatible
 specified.m:138:   with output modes.
 specified.m:170: Error in `pragma memo' declaration for predicate
-specified.m:170:   `specified.ap_li_fib/3':
+specified.m:170:   `specified.ap_li_fib'/3:
 specified.m:170:   not enough argument tabling methods specified.
 specified.m:210: Error in `pragma memo' declaration for predicate
-specified.m:210:   `specified.vp_ll_fib/3':
+specified.m:210:   `specified.vp_ll_fib'/3:
 specified.m:210:   argument 1: argument tabling method `output' is not
 specified.m:210:   compatible with input modes.
 specified.m:230: Error in `pragma memo' declaration for predicate
-specified.m:230:   `specified.vv_ll_fib/3':
+specified.m:230:   `specified.vv_ll_fib'/3:
 specified.m:230:   too many argument tabling methods specified.
Index: tests/invalid/spurious_mode_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/spurious_mode_error.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 spurious_mode_error.err_exp
--- tests/invalid/spurious_mode_error.err_exp	14 Sep 2005 05:26:51 -0000	1.3
+++ tests/invalid/spurious_mode_error.err_exp	5 Sep 2006 12:08:16 -0000
@@ -1,2 +1,2 @@
-spurious_mode_error.m:079: In clause for predicate `spurious_mode_error.foldit/4':
-spurious_mode_error.m:079:   error: undefined predicate `foobie/3'.
+spurious_mode_error.m:079: In clause for predicate `foldit'/4:
+spurious_mode_error.m:079:   error: undefined predicate `foobie'/3.
Index: tests/invalid/state_vars_test1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/state_vars_test1.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 state_vars_test1.err_exp
--- tests/invalid/state_vars_test1.err_exp	14 Sep 2005 05:26:51 -0000	1.6
+++ tests/invalid/state_vars_test1.err_exp	5 Sep 2006 12:08:16 -0000
@@ -1,6 +1,6 @@
 state_vars_test1.m:023: Error: cannot use !:X in this context;
 state_vars_test1.m:023:   however !.X may be used here.
-state_vars_test1.m:023: In clause for predicate `state_vars_test1.p/2':
+state_vars_test1.m:023: In clause for predicate `state_vars_test1.p'/2:
 state_vars_test1.m:023:   warning: variable `X' occurs only once in this scope.
 state_vars_test1.m:022: Warning: the condition of this if-then-else cannot
 state_vars_test1.m:022:   fail.
Index: tests/invalid/state_vars_test2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/state_vars_test2.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 state_vars_test2.err_exp
--- tests/invalid/state_vars_test2.err_exp	14 Sep 2005 05:26:51 -0000	1.7
+++ tests/invalid/state_vars_test2.err_exp	5 Sep 2006 12:08:17 -0000
@@ -1,6 +1,6 @@
 state_vars_test2.m:023: Error: state variable !:Y is not visible in this
 state_vars_test2.m:023:   context.
-state_vars_test2.m:023: In clause for predicate `state_vars_test2.p/2':
+state_vars_test2.m:023: In clause for predicate `state_vars_test2.p'/2:
 state_vars_test2.m:023:   warning: variable `Y' occurs only once in this scope.
 state_vars_test2.m:022: Warning: the condition of this if-then-else cannot
 state_vars_test2.m:022:   fail.
Index: tests/invalid/state_vars_test3.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/state_vars_test3.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 state_vars_test3.err_exp
--- tests/invalid/state_vars_test3.err_exp	27 Jul 2006 05:03:49 -0000	1.9
+++ tests/invalid/state_vars_test3.err_exp	5 Sep 2006 12:08:17 -0000
@@ -1,4 +1,6 @@
-state_vars_test3.m:021: Error: clause for function `state_vars_test3.f/2'
+state_vars_test3.m:021: Error: clause for function `state_vars_test3.f'/2
 state_vars_test3.m:021:   without preceding `func' declaration.
 state_vars_test3.m:021: Error: !Y cannot be a function result.
 state_vars_test3.m:021:   You probably meant !.Y or !:Y.
+state_vars_test3.m:015: Error: no clauses for function `f'/1.
+state_vars_test3.m:021: Error: no clauses for function `f'/2.
Index: tests/invalid/state_vars_test3.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/state_vars_test3.m,v
retrieving revision 1.3
diff -u -b -r1.3 state_vars_test3.m
--- tests/invalid/state_vars_test3.m	1 Aug 2002 00:41:39 -0000	1.3
+++ tests/invalid/state_vars_test3.m	5 Sep 2006 14:55:29 -0000
@@ -19,4 +19,3 @@
     % Illegally uses !Y as a func result.
     %
 f(!X) = !Y.
-
Index: tests/invalid/state_vars_test4.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/state_vars_test4.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 state_vars_test4.err_exp
--- tests/invalid/state_vars_test4.err_exp	14 Jun 2006 08:14:55 -0000	1.9
+++ tests/invalid/state_vars_test4.err_exp	5 Sep 2006 12:08:18 -0000
@@ -1,10 +1,9 @@
 state_vars_test4.m:021: Error: !X cannot be a lambda argument.
 state_vars_test4.m:021:   Perhaps you meant !.X or !:X.
 state_vars_test4.m:021: In clause for `f(in) = out':
-state_vars_test4.m:021:   in argument 1 of call to function `list.foldl/3':
+state_vars_test4.m:021:   in argument 1 of call to function `list.foldl'/3:
 state_vars_test4.m:021:   mode error: variable `V_5' has instantiatedness
 state_vars_test4.m:021:   `free',
 state_vars_test4.m:021:   expected instantiatedness was `(func((ground >>
 state_vars_test4.m:021:   ground), (ground >> ground)) = (free >> ground) is
 state_vars_test4.m:021:   det)'.
-For more information, recompile with `-E'.
Index: tests/invalid/state_vars_test5.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/state_vars_test5.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 state_vars_test5.err_exp
--- tests/invalid/state_vars_test5.err_exp	14 Jun 2006 08:14:55 -0000	1.9
+++ tests/invalid/state_vars_test5.err_exp	5 Sep 2006 12:08:18 -0000
@@ -1,4 +1,4 @@
-state_vars_test5.m:021: In clause for predicate `state_vars_test5.p/1':
+state_vars_test5.m:021: In clause for predicate `state_vars_test5.p'/1:
 state_vars_test5.m:021:   warning: variable `STATE_VARIABLE_X' occurs only once
 state_vars_test5.m:021:   in this scope.
 state_vars_test5.m:021: In clause for `p(out)':
@@ -7,4 +7,3 @@
 state_vars_test5.m:021:   Final instantiatedness of `STATE_VARIABLE_X' was
 state_vars_test5.m:021:   `free',
 state_vars_test5.m:021:   expected final instantiatedness was `ground'.
-For more information, recompile with `-E'.
Index: tests/invalid/transitive_import_class.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/transitive_import_class.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 transitive_import_class.err_exp
--- tests/invalid/transitive_import_class.err_exp	14 Sep 2005 05:26:52 -0000	1.4
+++ tests/invalid/transitive_import_class.err_exp	5 Sep 2006 12:06:58 -0000
@@ -1,11 +1,14 @@
-transitive_import_class.m:017: In clause for function `transitive_import_class.semidet_id/1':
+transitive_import_class.m:017: In clause for function `semidet_id'/1:
 transitive_import_class.m:017:   in function result term of clause head:
-transitive_import_class.m:017:   error: undefined symbol `transitive_import_class3.to_int/1'
+transitive_import_class.m:017:   error: undefined symbol
+transitive_import_class.m:017:   `transitive_import_class3.to_int/1'
 transitive_import_class.m:017:   (the module `transitive_import_class3' has not
 transitive_import_class.m:017:     been imported).
-transitive_import_class.m:017: In clause for function `transitive_import_class.semidet_id/1':
+transitive_import_class.m:017: In clause for function `semidet_id'/1:
 transitive_import_class.m:017:   in function result term of clause head:
-transitive_import_class.m:017:   in argument 1 of functor `transitive_import_class3.to_int/1':
-transitive_import_class.m:017:   error: undefined symbol `transitive_import_class3.from_int/1'
+transitive_import_class.m:017:   in argument 1 of functor
+transitive_import_class.m:017:   `transitive_import_class3.to_int/1':
+transitive_import_class.m:017:   error: undefined symbol
+transitive_import_class.m:017:   `transitive_import_class3.from_int/1'
 transitive_import_class.m:017:   (the module `transitive_import_class3' has not
 transitive_import_class.m:017:     been imported).
Index: tests/invalid/tricky_assert1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/tricky_assert1.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 tricky_assert1.err_exp
--- tests/invalid/tricky_assert1.err_exp	14 Jun 2006 08:14:55 -0000	1.6
+++ tests/invalid/tricky_assert1.err_exp	5 Sep 2006 12:08:22 -0000
@@ -1,6 +1,6 @@
 tricky_assert1.m:005: In interface for module `tricky_assert1':
 tricky_assert1.m:005:   error: exported promise refers to predicate
-tricky_assert1.m:005:   `tricky_assert1.local/0' which is defined in the
+tricky_assert1.m:005:   `tricky_assert1.local'/0 which is defined in the
 tricky_assert1.m:005:   implementation section of module `tricky_assert1'.
 tricky_assert1.m:005:   Either move the promise into the implementation section
 tricky_assert1.m:005:   or move the definition into the interface.
Index: tests/invalid/type_inf_loop.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/type_inf_loop.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 type_inf_loop.err_exp
--- tests/invalid/type_inf_loop.err_exp	14 Jun 2006 08:14:55 -0000	1.5
+++ tests/invalid/type_inf_loop.err_exp	5 Sep 2006 12:08:23 -0000
@@ -1,11 +1,10 @@
 type_inf_loop.m:001: Warning: interface for module `type_inf_loop' does not
 type_inf_loop.m:001:   export anything.
-type_inf_loop.m:004: Error: clause for predicate `type_inf_loop.loop/1'
+type_inf_loop.m:004: Error: clause for predicate `type_inf_loop.loop'/1
 type_inf_loop.m:004:   without preceding `pred' declaration.
-Type inference iteration limit exceeded.
-This probably indicates that your program has a type error.
-You should declare the types explicitly.
-(The current limit is 60 iterations.  You can use the
-`--type-inference-iteration-limit' option to increase the limit).
+Type inference iteration limit exceeded. This probably indicates that your
+  program has a type error. You should declare the types explicitly. (The
+  current limit is 60 iterations. You can use the
+  `--type-inference-iteration-limit' option to increase the limit).
 type_inf_loop.m:004: Inferred :- pred loop((pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred (pred T1))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))).
 For more information, recompile with `-E'.
Index: tests/invalid/type_loop.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/type_loop.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 type_loop.err_exp
--- tests/invalid/type_loop.err_exp	14 Sep 2005 05:26:52 -0000	1.4
+++ tests/invalid/type_loop.err_exp	2 Sep 2006 13:00:24 -0000
@@ -1 +1 @@
-type_loop.m:016: Error: circular equivalence type `type_loop.foo/0'.
+type_loop.m:016: Error: circular equivalence type `type_loop.foo'/0.
Index: tests/invalid/type_mismatch.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/type_mismatch.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 type_mismatch.err_exp
--- tests/invalid/type_mismatch.err_exp	14 Sep 2005 05:26:52 -0000	1.5
+++ tests/invalid/type_mismatch.err_exp	5 Sep 2006 12:08:24 -0000
@@ -1,28 +1,28 @@
-type_mismatch.m:019: In clause for predicate `type_mismatch.p1/2':
+type_mismatch.m:019: In clause for predicate `p1'/2:
 type_mismatch.m:019:   in unification of variable `Tuple'
 type_mismatch.m:019:   and term `f1(V_5, Field, V_6)':
 type_mismatch.m:019:   type error in argument(s) of functor `f1/3'.
 type_mismatch.m:019:   Argument 2 (Field) has type `float',
 type_mismatch.m:019:   expected type was `int'.
-type_mismatch.m:022: In clause for predicate `type_mismatch.p2/2':
+type_mismatch.m:022: In clause for predicate `p2'/2:
 type_mismatch.m:022:   in unification of variable `Tuple'
 type_mismatch.m:022:   and term `f2(V_5, Field, V_6)':
 type_mismatch.m:022:   type error in argument(s) of functor `f2/3'.
 type_mismatch.m:022:   Argument 2 (Field) has type `float',
 type_mismatch.m:022:   expected type was `int'.
-type_mismatch.m:025: In clause for predicate `type_mismatch.p3/2':
+type_mismatch.m:025: In clause for predicate `p3'/2:
 type_mismatch.m:025:   in unification of variable `Tuple'
 type_mismatch.m:025:   and term `f3(V_5, Field, V_6)':
 type_mismatch.m:025:   type error in argument(s) of functor `f3/3'.
 type_mismatch.m:025:   Argument 2 (Field) has type `(some [F3c] F3c)',
 type_mismatch.m:025:   expected type was `(some [F3b] F3b)'.
-type_mismatch.m:032: In clause for predicate `type_mismatch.p4a/2':
+type_mismatch.m:032: In clause for predicate `p4a'/2:
 type_mismatch.m:032:   in unification of variable `Tuple'
 type_mismatch.m:032:   and term `f4(Field, V_5, V_6)':
 type_mismatch.m:032:   type error in argument(s) of functor `f4/3'.
 type_mismatch.m:032:   Argument 1 (Field) has type `float',
 type_mismatch.m:032:   expected type was `(some [F4] F4)'.
-type_mismatch.m:035: In clause for predicate `type_mismatch.p4b/3':
+type_mismatch.m:035: In clause for predicate `p4b'/3:
 type_mismatch.m:035:   in unification of variable `Tuple'
 type_mismatch.m:035:   and term `f4(Field1, Field2, V_7)':
 type_mismatch.m:035:   type error in argument(s) of functor `f4/3'.
Index: tests/invalid/type_spec.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/type_spec.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 type_spec.err_exp
--- tests/invalid/type_spec.err_exp	14 Sep 2005 05:26:52 -0000	1.7
+++ tests/invalid/type_spec.err_exp	5 Sep 2006 12:08:57 -0000
@@ -1,5 +1,5 @@
 type_spec.m:010: In `:- pragma type_spec' declaration for predicate
-type_spec.m:010:   `type_spec.type_spec1/1':
+type_spec.m:010:   `type_spec.type_spec1'/1:
 type_spec.m:010:   error: variable `U' does not occur in the `:- pred'
 type_spec.m:010:   declaration.
 type_spec.m:011: Error: `:- pragma type_spec' declaration for
@@ -8,13 +8,13 @@
 type_spec.m:013:   `type_spec.type_spec1'/2 without corresponding `pred' or
 type_spec.m:013:   `func' declaration.
 type_spec.m:024: In `:- pragma type_spec' declaration for predicate
-type_spec.m:024:   `type_spec.type_spec2/1':
+type_spec.m:024:   `type_spec.type_spec2'/1:
 type_spec.m:024:   error: the substitution includes the existentially
 type_spec.m:024:   quantified type variable `U'.
 type_spec.m:026: In `:- pragma type_spec' declaration for predicate
-type_spec.m:026:   `type_spec.type_spec2/1':
+type_spec.m:026:   `type_spec.type_spec2'/1:
 type_spec.m:026:   error: variable `U' occurs on both sides of the
 type_spec.m:026:   substitution.
 type_spec.m:028: In `:- pragma type_spec' declaration for predicate
-type_spec.m:028:   `type_spec.type_spec2/1':
+type_spec.m:028:   `type_spec.type_spec2'/1:
 type_spec.m:028:   error: variable `U' has multiple replacement types.
Index: tests/invalid/typeclass_constraint_extra_var.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_constraint_extra_var.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 typeclass_constraint_extra_var.err_exp
--- tests/invalid/typeclass_constraint_extra_var.err_exp	14 Jun 2006 08:14:55 -0000	1.7
+++ tests/invalid/typeclass_constraint_extra_var.err_exp	5 Sep 2006 12:08:27 -0000
@@ -1,5 +1,5 @@
 typeclass_constraint_extra_var.m:011: In declaration for predicate
-typeclass_constraint_extra_var.m:011:   `typeclass_constraint_extra_var.mg/2':
+typeclass_constraint_extra_var.m:011:   `typeclass_constraint_extra_var.mg'/2:
 typeclass_constraint_extra_var.m:011:   error in type class constraints: type
 typeclass_constraint_extra_var.m:011:   variable U occurs in the constraints,
 typeclass_constraint_extra_var.m:011:   but is not determined by the
Index: tests/invalid/typeclass_mode_2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_mode_2.err_exp,v
retrieving revision 1.1
diff -u -b -r1.1 typeclass_mode_2.err_exp
--- tests/invalid/typeclass_mode_2.err_exp	16 Jan 2006 03:08:16 -0000	1.1
+++ tests/invalid/typeclass_mode_2.err_exp	5 Sep 2006 12:08:32 -0000
@@ -1,8 +1,8 @@
 typeclass_mode_2.m:005: Error: mode declaration for type class method
 typeclass_mode_2.m:005:   `typeclass_mode_2.p'/1 without corresponding
 typeclass_mode_2.m:005:   predicate method declaration.
-typeclass_mode_2.m:010: Error: clause for predicate `typeclass_mode_2.p/1'
+typeclass_mode_2.m:010: Error: clause for predicate `typeclass_mode_2.p'/1
 typeclass_mode_2.m:010:   without preceding `pred' declaration.
 typeclass_mode_2.m:010: Inferred :- pred p(T1).
-typeclass_mode_2.m:010: Error: no mode declaration for predicate
-typeclass_mode_2.m:010:   `typeclass_mode_2.p/1'.
+typeclass_mode_2.m:010: Error: no mode declaration for predicate `p'/1.
+For more information, recompile with `-E'.
Index: tests/invalid/typeclass_mode_3.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_mode_3.err_exp,v
retrieving revision 1.1
diff -u -b -r1.1 typeclass_mode_3.err_exp
--- tests/invalid/typeclass_mode_3.err_exp	16 Jan 2006 03:08:16 -0000	1.1
+++ tests/invalid/typeclass_mode_3.err_exp	5 Sep 2006 12:08:33 -0000
@@ -2,4 +2,4 @@
 typeclass_mode_3.m:007:   `typeclass_mode_3.p'/1 without corresponding
 typeclass_mode_3.m:007:   predicate method declaration.
 typeclass_mode_3.m:004: Error: no mode declaration for exported predicate
-typeclass_mode_3.m:004:   `typeclass_mode_3.p/1'.
+typeclass_mode_3.m:004:   `typeclass_mode_3.p'/1.
Index: tests/invalid/typeclass_mode_4.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_mode_4.err_exp,v
retrieving revision 1.1
diff -u -b -r1.1 typeclass_mode_4.err_exp
--- tests/invalid/typeclass_mode_4.err_exp	16 Jan 2006 03:08:16 -0000	1.1
+++ tests/invalid/typeclass_mode_4.err_exp	5 Sep 2006 12:08:33 -0000
@@ -2,4 +2,4 @@
 typeclass_mode_4.m:007:   `typeclass_mode_4.p'/1 without corresponding
 typeclass_mode_4.m:007:   predicate method declaration.
 typeclass_mode_4.m:004: Error: no mode declaration for exported predicate
-typeclass_mode_4.m:004:   `typeclass_mode_4.p/1'.
+typeclass_mode_4.m:004:   `typeclass_mode_4.p'/1.
Index: tests/invalid/typeclass_test_1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_1.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 typeclass_test_1.err_exp
--- tests/invalid/typeclass_test_1.err_exp	14 Sep 2005 05:26:53 -0000	1.7
+++ tests/invalid/typeclass_test_1.err_exp	5 Sep 2006 12:08:34 -0000
@@ -1,6 +1,6 @@
 typeclass_test_1.m:001: Warning: module should start with a `:- module' declaration.
 typeclass_test_1.m:014: Error: expected `pred(<Name> / <Arity>) is <InstanceName>': type_num is foo_type_num.
 typeclass_test_1.m:017: Syntax error at variable `_': operator or `.' expected.
-typeclass_test_1.m:007: In clause for predicate `typeclass_test_1.main/2':
-typeclass_test_1.m:007:   unsatisfiable typeclass constraint(s):
+typeclass_test_1.m:007: In clause for predicate `main'/2:
+typeclass_test_1.m:007:   unsatisfiable typeclass constraint:
 typeclass_test_1.m:007:   `typeclass_test_1.numbered_type(int)'.
Index: tests/invalid/typeclass_test_12.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_12.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 typeclass_test_12.err_exp
--- tests/invalid/typeclass_test_12.err_exp	14 Jun 2006 08:14:56 -0000	1.3
+++ tests/invalid/typeclass_test_12.err_exp	5 Sep 2006 12:08:36 -0000
@@ -1,4 +1,4 @@
-typeclass_test_12.m:003: In declaration for predicate `typeclass_test_12.p/0':
+typeclass_test_12.m:003: In declaration for predicate `typeclass_test_12.p'/0:
 typeclass_test_12.m:003:   error in type class constraints: type variable T
 typeclass_test_12.m:003:   occurs in the constraints, but is not determined by
 typeclass_test_12.m:003:   the predicate's argument types.
@@ -21,7 +21,7 @@
 typeclass_test_12.m:003:   determined.
 typeclass_test_12.m:003:   See the "Functional dependencies" section of the
 typeclass_test_12.m:003:   reference manual for details.
-typeclass_test_12.m:005: In declaration for function `typeclass_test_12.q/0':
+typeclass_test_12.m:005: In declaration for function `typeclass_test_12.q'/0:
 typeclass_test_12.m:005:   error in type class constraints: type variable T
 typeclass_test_12.m:005:   occurs in the constraints, but is not determined by
 typeclass_test_12.m:005:   the function's argument or result types.
Index: tests/invalid/typeclass_test_2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_2.err_exp,v
retrieving revision 1.11
diff -u -b -r1.11 typeclass_test_2.err_exp
--- tests/invalid/typeclass_test_2.err_exp	14 Sep 2005 05:26:53 -0000	1.11
+++ tests/invalid/typeclass_test_2.err_exp	5 Sep 2006 12:08:36 -0000
@@ -1,8 +1,8 @@
 typeclass_test_2.m:020: Error: expected `pred(<Name> / <Arity>) is <InstanceName>': type_num / 0 is foo_type_num.
 typeclass_test_2.m:023: Error: clause for function
-typeclass_test_2.m:023:   `typeclass_test_2.foo_type_num/1'
+typeclass_test_2.m:023:   `typeclass_test_2.foo_type_num'/1
 typeclass_test_2.m:023:   without preceding `func' declaration.
-typeclass_test_2.m:010: In clause for predicate `typeclass_test_2.main/2':
-typeclass_test_2.m:010:   unsatisfiable typeclass constraint(s):
+typeclass_test_2.m:010: In clause for predicate `main'/2:
+typeclass_test_2.m:010:   unsatisfiable typeclass constraint:
 typeclass_test_2.m:010:   `typeclass_test_2.numbered_type(int)'.
 typeclass_test_2.m:023: Inferred :- func foo_type_num(T1) = int.
Index: tests/invalid/typeclass_test_5.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_5.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 typeclass_test_5.err_exp
--- tests/invalid/typeclass_test_5.err_exp	14 Sep 2005 05:26:53 -0000	1.9
+++ tests/invalid/typeclass_test_5.err_exp	6 Sep 2006 14:43:17 -0000
@@ -1,6 +1,6 @@
-typeclass_test_5.m:020: In instance declaration for `typeclass_test_5.c2(int)':
+typeclass_test_5.m:020: In instance declaration for `typeclass_test_5.c2'(int):
 typeclass_test_5.m:020:   multiple implementations of type class predicate
-typeclass_test_5.m:020:   method `typeclass_test_5.p/1'.
+typeclass_test_5.m:020:   method `typeclass_test_5.p'/1.
 typeclass_test_5.m:021: First definition appears here.
 typeclass_test_5.m:022: Subsequent definition appears here.
 typeclass_test_5.m:020: In instance declaration for `typeclass_test_5.c2(int)':
Index: tests/invalid/typeclass_test_7.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_7.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 typeclass_test_7.err_exp
--- tests/invalid/typeclass_test_7.err_exp	14 Sep 2005 05:26:53 -0000	1.5
+++ tests/invalid/typeclass_test_7.err_exp	5 Sep 2006 12:08:39 -0000
@@ -1,3 +1,3 @@
-typeclass_test_7.m:010: In clause for predicate `typeclass_test_7.p/2':
-typeclass_test_7.m:010:   unsatisfiable typeclass constraint(s):
+typeclass_test_7.m:010: In clause for predicate `p'/2:
+typeclass_test_7.m:010:   unsatisfiable typeclass constraint:
 typeclass_test_7.m:010:   `typeclass_test_7.numbered_type(T)'.
Index: tests/invalid/typeclass_test_8.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/typeclass_test_8.err_exp,v
retrieving revision 1.8
diff -u -b -r1.8 typeclass_test_8.err_exp
--- tests/invalid/typeclass_test_8.err_exp	14 Jun 2006 08:14:56 -0000	1.8
+++ tests/invalid/typeclass_test_8.err_exp	5 Sep 2006 12:08:39 -0000
@@ -1,7 +1,7 @@
-typeclass_test_8.m:004: In predicate `typeclass_test_8.main/2':
+typeclass_test_8.m:004: In predicate `typeclass_test_8.main'/2:
 typeclass_test_8.m:004:   type error: unsatisfied typeclass constraint:
 typeclass_test_8.m:004:       `typeclass_test_8.fooable(T)'
-typeclass_test_8.m:004: In predicate `typeclass_test_8.main/2':
+typeclass_test_8.m:004: In predicate `typeclass_test_8.main'/2:
 typeclass_test_8.m:004:   warning: unresolved polymorphism.
 typeclass_test_8.m:004:   The variable with an unbound type was:
 typeclass_test_8.m:004:       X: T
Index: tests/invalid/types.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/types.err_exp,v
retrieving revision 1.15
diff -u -b -r1.15 types.err_exp
--- tests/invalid/types.err_exp	27 Jul 2006 05:03:49 -0000	1.15
+++ tests/invalid/types.err_exp	6 Sep 2006 14:43:18 -0000
@@ -7,35 +7,35 @@
 types.m:003:   defined.
 types.m:003: Error: constructor `types.f/1' for type `types.t/0' multiply
 types.m:003:   defined.
-types.m:017: Error: clause for predicate `types.r/0'
+types.m:017: Error: clause for predicate `types.r'/0
 types.m:017:   without preceding `pred' declaration.
-types.m:020: Error: clause for predicate `types.a/1'
+types.m:020: Error: clause for predicate `types.a'/1
 types.m:020:   without preceding `pred' declaration.
-types.m:012: In clause for predicate `types.q/0':
-types.m:012:   error: undefined predicate `zzzzzzzz/0'.
-types.m:013: In clause for predicate `types.q/0':
-types.m:013:   in argument 1 of call to predicate `p/1':
+types.m:005: Error: no clauses for predicate `p'/1.
+types.m:012: In clause for predicate `q'/0:
+types.m:012:   error: undefined predicate `zzzzzzzz'/0.
+types.m:013: In clause for predicate `q'/0:
+types.m:013:   in argument 1 of call to predicate `p'/1:
 types.m:013:   type error: argument has type `int',
 types.m:013:   expected type was `(pred)'.
-	The partial type assignment was:
-	V_1: (pred)
-	V_2: int
-
-types.m:014: In clause for predicate `types.q/0':
+types.m:013:   The partial type assignment was:
+types.m:013:     V_1: (pred)
+types.m:013:     V_2: int
+types.m:014: In clause for predicate `q'/0:
 types.m:014:   error: wrong number of arguments (0; should be 1)
 types.m:014:   in call to predicate `p'.
-types.m:039: In clause for predicate `types.bar/1':
+types.m:039: In clause for predicate `bar'/1:
 types.m:039:   type error in unification of variable `X'
 types.m:039:   and constant `0'.
 types.m:039:   variable `X' has type `(some [BarTypeParam] BarTypeParam)',
 types.m:039:   constant `0' has type `int'.
-	The partial type assignment was:
-	some [BarTypeParam_1]
-	X_2: BarTypeParam
-
-types.m:018: In clause for predicate `types.r/0':
-types.m:018:   error: undefined predicate `s/0'.
-types.m:020: In clause for predicate `types.a/1':
-types.m:020:   error: undefined predicate `b/1'.
+types.m:039:   The partial type assignment was:
+types.m:039:     some [BarTypeParam_1]
+types.m:039:     X_2: BarTypeParam
+types.m:050: Error: no clauses for predicate `bar2'/1.
+types.m:018: In clause for predicate `r'/0:
+types.m:018:   error: undefined predicate `s'/0.
+types.m:020: In clause for predicate `a'/1:
+types.m:020:   error: undefined predicate `b'/1.
 types.m:048: Error: abstract declaration for type `types.t'/2 has no
 types.m:048:   corresponding definition.
Index: tests/invalid/unbound_type_vars.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/unbound_type_vars.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 unbound_type_vars.err_exp
--- tests/invalid/unbound_type_vars.err_exp	14 Jun 2006 08:14:56 -0000	1.7
+++ tests/invalid/unbound_type_vars.err_exp	5 Sep 2006 12:08:41 -0000
@@ -1,6 +1,6 @@
 unbound_type_vars.m:014: Error: type variable in superclass constraint is not a parameter of this type class: c1(_1, _2).
 unbound_type_vars.m:018: Error: unbound type variable(s) in constraints on instance declaration: c1(int, float) <= c3(_1).
-unbound_type_vars.m:021: In declaration for predicate `unbound_type_vars.p1/1':
+unbound_type_vars.m:021: In declaration for predicate `unbound_type_vars.p1'/1:
 unbound_type_vars.m:021:   error in type class constraints: type variable T2
 unbound_type_vars.m:021:   occurs in the constraints, but is not determined by
 unbound_type_vars.m:021:   the predicate's argument types.
@@ -23,7 +23,7 @@
 unbound_type_vars.m:021:   determined.
 unbound_type_vars.m:021:   See the "Functional dependencies" section of the
 unbound_type_vars.m:021:   reference manual for details.
-unbound_type_vars.m:024: In declaration for predicate `unbound_type_vars.p2/2':
+unbound_type_vars.m:024: In declaration for predicate `unbound_type_vars.p2'/2:
 unbound_type_vars.m:024:   error in type class constraints: type variable T3
 unbound_type_vars.m:024:   occurs in the constraints, but is not determined by
 unbound_type_vars.m:024:   the predicate's argument types.
@@ -46,7 +46,7 @@
 unbound_type_vars.m:024:   determined.
 unbound_type_vars.m:024:   See the "Functional dependencies" section of the
 unbound_type_vars.m:024:   reference manual for details.
-unbound_type_vars.m:028: In declaration for predicate `unbound_type_vars.p3/1':
+unbound_type_vars.m:028: In declaration for predicate `unbound_type_vars.p3'/1:
 unbound_type_vars.m:028:   error in type class constraints: type variable T2
 unbound_type_vars.m:028:   occurs in the constraints, but is not determined by
 unbound_type_vars.m:028:   the predicate's argument types.
@@ -69,7 +69,7 @@
 unbound_type_vars.m:028:   determined.
 unbound_type_vars.m:028:   See the "Functional dependencies" section of the
 unbound_type_vars.m:028:   reference manual for details.
-unbound_type_vars.m:031: In declaration for predicate `unbound_type_vars.p4/1':
+unbound_type_vars.m:031: In declaration for predicate `unbound_type_vars.p4'/1:
 unbound_type_vars.m:031:   error in type class constraints: type variable T2
 unbound_type_vars.m:031:   occurs in the constraints, but is not determined by
 unbound_type_vars.m:031:   the predicate's argument types.
@@ -92,7 +92,7 @@
 unbound_type_vars.m:031:   determined.
 unbound_type_vars.m:031:   See the "Functional dependencies" section of the
 unbound_type_vars.m:031:   reference manual for details.
-unbound_type_vars.m:034: In declaration for predicate `unbound_type_vars.p5/1':
+unbound_type_vars.m:034: In declaration for predicate `unbound_type_vars.p5'/1:
 unbound_type_vars.m:034:   error in type class constraints: type variable T2
 unbound_type_vars.m:034:   occurs in the constraints, but is not determined by
 unbound_type_vars.m:034:   the predicate's argument types.
@@ -115,6 +115,6 @@
 unbound_type_vars.m:034:   determined.
 unbound_type_vars.m:034:   See the "Functional dependencies" section of the
 unbound_type_vars.m:034:   reference manual for details.
-unbound_type_vars.m:034: In declaration of predicate `unbound_type_vars.p5/1':
+unbound_type_vars.m:034: In declaration of predicate `unbound_type_vars.p5'/1:
 unbound_type_vars.m:034:   type variable T2 is universally constrained, but is
 unbound_type_vars.m:034:   existentially quantified.
Index: tests/invalid/undeclared_mode.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/undeclared_mode.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 undeclared_mode.err_exp
--- tests/invalid/undeclared_mode.err_exp	14 Sep 2005 05:26:54 -0000	1.3
+++ tests/invalid/undeclared_mode.err_exp	5 Sep 2006 12:08:42 -0000
@@ -1,3 +1,4 @@
 undeclared_mode.m:032: Error: no mode declaration for predicate
-undeclared_mode.m:032:   `undeclared_mode.sort_of_factorial/2'.
+undeclared_mode.m:032:   `sort_of_factorial'/2.
 undeclared_mode.m:032: Inferred :- mode sort_of_factorial(di, uo).
+For more information, recompile with `-E'.
Index: tests/invalid/undef_mod_qual.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/undef_mod_qual.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 undef_mod_qual.err_exp
--- tests/invalid/undef_mod_qual.err_exp	14 Sep 2005 05:26:54 -0000	1.3
+++ tests/invalid/undef_mod_qual.err_exp	5 Sep 2006 12:06:59 -0000
@@ -1,2 +1,2 @@
-undef_mod_qual.m:012: In clause for predicate `undef_mod_qual.main/2':
-undef_mod_qual.m:012:   error: undefined predicate `foo.bletchx/2'.
+undef_mod_qual.m:012: In clause for predicate `main'/2:
+undef_mod_qual.m:012:   error: undefined predicate `foo.bletchx'/2.
Index: tests/invalid/undef_mode_and_no_clauses.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/undef_mode_and_no_clauses.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 undef_mode_and_no_clauses.err_exp
--- tests/invalid/undef_mode_and_no_clauses.err_exp	27 Jul 2006 05:03:49 -0000	1.6
+++ tests/invalid/undef_mode_and_no_clauses.err_exp	5 Sep 2006 12:08:45 -0000
@@ -1,3 +1,4 @@
 undef_mode_and_no_clauses.m:012: In mode declaration for predicate
 undef_mode_and_no_clauses.m:012:   `undef_mode_and_no_clauses.p'/2:
 undef_mode_and_no_clauses.m:012:   error: undefined mode `result'/1.
+undef_mode_and_no_clauses.m:011: Error: no clauses for predicate `p'/2.
Index: tests/invalid/undef_symbol.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/undef_symbol.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 undef_symbol.err_exp
--- tests/invalid/undef_symbol.err_exp	14 Sep 2005 05:26:54 -0000	1.4
+++ tests/invalid/undef_symbol.err_exp	2 Sep 2006 15:47:56 -0000
@@ -1,8 +1,8 @@
-undef_symbol.m:014: In clause for predicate `undef_symbol.main/2':
-undef_symbol.m:014:   error: undefined predicate `undef_symbol.r/2'.
-undef_symbol.m:019: In clause for predicate `undef_symbol.p/2':
-undef_symbol.m:019:   error: undefined predicate `string.append/3'
+undef_symbol.m:014: In clause for predicate `main'/2:
+undef_symbol.m:014:   error: undefined predicate `undef_symbol.r'/2.
+undef_symbol.m:019: In clause for predicate `p'/2:
+undef_symbol.m:019:   error: undefined predicate `string.append'/3
 undef_symbol.m:019:   (the module `string' has not been imported).
-undef_symbol.m:025: In clause for predicate `undef_symbol.q/2':
+undef_symbol.m:025: In clause for predicate `q'/2:
 undef_symbol.m:025:   error: undefined symbol `term.context/2'
 undef_symbol.m:025:   (the module `term' has not been imported).
Index: tests/invalid/unify_mode_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/unify_mode_error.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 unify_mode_error.err_exp
--- tests/invalid/unify_mode_error.err_exp	15 Jun 2006 04:48:36 -0000	1.5
+++ tests/invalid/unify_mode_error.err_exp	5 Sep 2006 12:08:49 -0000
@@ -1,5 +1,4 @@
 unify_mode_error.m:015: In clause for `foo(in, out)':
-unify_mode_error.m:015:   in argument 2 of call to predicate `builtin.unify/2':
+unify_mode_error.m:015:   in argument 2 of call to predicate `builtin.unify'/2:
 unify_mode_error.m:015:   mode error: variable `Y' has instantiatedness `free',
 unify_mode_error.m:015:   expected instantiatedness was `ground'.
-For more information, recompile with `-E'.
Index: tests/invalid/uniq_modes.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/uniq_modes.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 uniq_modes.err_exp
--- tests/invalid/uniq_modes.err_exp	14 Jun 2006 08:14:56 -0000	1.5
+++ tests/invalid/uniq_modes.err_exp	5 Sep 2006 12:08:50 -0000
@@ -1,6 +1,5 @@
 uniq_modes.m:012: In clause for `main(di, uo)':
-uniq_modes.m:012:   in argument 2 of call to predicate `io.write/3':
+uniq_modes.m:012:   in argument 2 of call to predicate `io.write'/3:
 uniq_modes.m:012:   mode error: variable `In' has instantiatedness
 uniq_modes.m:012:   `mostly_unique',
 uniq_modes.m:012:   expected instantiatedness was `unique'.
-For more information, recompile with `-E'.
Index: tests/invalid/uniq_neg.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/uniq_neg.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 uniq_neg.err_exp
--- tests/invalid/uniq_neg.err_exp	14 Jun 2006 08:14:56 -0000	1.5
+++ tests/invalid/uniq_neg.err_exp	5 Sep 2006 12:08:50 -0000
@@ -1,6 +1,5 @@
 uniq_neg.m:025: In clause for `unify(in, in, in, in, di, uo)':
-uniq_neg.m:025:   in argument 3 of call to predicate `uniq_neg.occurs/4':
+uniq_neg.m:025:   in argument 3 of call to predicate `uniq_neg.occurs'/4:
 uniq_neg.m:025:   mode error: variable `DCG_0' has instantiatedness
 uniq_neg.m:025:   `mostly_unique',
 uniq_neg.m:025:   expected instantiatedness was `unique'.
-For more information, recompile with `-E'.
Index: tests/invalid/unsatisfiable_constraint.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/unsatisfiable_constraint.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 unsatisfiable_constraint.err_exp
--- tests/invalid/unsatisfiable_constraint.err_exp	14 Jun 2006 08:14:56 -0000	1.5
+++ tests/invalid/unsatisfiable_constraint.err_exp	5 Sep 2006 12:08:51 -0000
@@ -1,9 +1,9 @@
-unsatisfiable_constraint.m:038: In predicate `unsatisfiable_constraint.test/1':
+unsatisfiable_constraint.m:038: In predicate `unsatisfiable_constraint.test'/1:
 unsatisfiable_constraint.m:038:   type error: unsatisfied typeclass constraints:
 unsatisfiable_constraint.m:038:       `unsatisfiable_constraint.a(A, B, A, V_8)'
 unsatisfiable_constraint.m:038:       `unsatisfiable_constraint.a(A, B, C, V_14)'
 unsatisfiable_constraint.m:038:       `unsatisfiable_constraint.b(A, C)'
-unsatisfiable_constraint.m:038: In predicate `unsatisfiable_constraint.test/1':
+unsatisfiable_constraint.m:038: In predicate `unsatisfiable_constraint.test'/1:
 unsatisfiable_constraint.m:038:   warning: unresolved polymorphism.
 unsatisfiable_constraint.m:038:   The variables with unbound types were:
 unsatisfiable_constraint.m:038:       C: C
Index: tests/invalid/unsatisfiable_super.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/unsatisfiable_super.err_exp,v
retrieving revision 1.2
diff -u -b -r1.2 unsatisfiable_super.err_exp
--- tests/invalid/unsatisfiable_super.err_exp	14 Sep 2005 05:26:55 -0000	1.2
+++ tests/invalid/unsatisfiable_super.err_exp	5 Sep 2006 12:08:51 -0000
@@ -1,3 +1,3 @@
-unsatisfiable_super.m:015: In clause for predicate `unsatisfiable_super.test/3':
-unsatisfiable_super.m:015:   unsatisfiable typeclass constraint(s):
+unsatisfiable_super.m:015: In clause for predicate `test'/3:
+unsatisfiable_super.m:015:   unsatisfiable typeclass constraint:
 unsatisfiable_super.m:015:   `unsatisfiable_super.foo(B, int)'.
Index: tests/invalid/user_eq_dummy.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/user_eq_dummy.err_exp,v
retrieving revision 1.1
diff -u -b -r1.1 user_eq_dummy.err_exp
--- tests/invalid/user_eq_dummy.err_exp	14 Jun 2006 08:14:56 -0000	1.1
+++ tests/invalid/user_eq_dummy.err_exp	6 Sep 2006 14:43:25 -0000
@@ -1,10 +1,10 @@
 user_eq_dummy.m:010: Error: the type `user_eq_dummy.foo'/0 is not allowed to
-user_eq_dummy.m:010:   have user-defined equality or comparison. Discriminated
-user_eq_dummy.m:010:   unions whose body consists of a single zero-arity
-user_eq_dummy.m:010:   constructor cannot have user-defined equality or
-user_eq_dummy.m:010:   comparison.
+user_eq_dummy.m:010:   have user-defined equality or comparison.
+user_eq_dummy.m:010:   Discriminated unions whose body consists of a single
+user_eq_dummy.m:010:   zero-arity constructor cannot have user-defined equality
+user_eq_dummy.m:010:   or comparison.
 user_eq_dummy.m:014: Error: the type `user_eq_dummy.bar'/0 is not allowed to
-user_eq_dummy.m:014:   have user-defined equality or comparison. Discriminated
-user_eq_dummy.m:014:   unions whose body consists of a single zero-arity
-user_eq_dummy.m:014:   constructor cannot have user-defined equality or
-user_eq_dummy.m:014:   comparison.
+user_eq_dummy.m:014:   have user-defined equality or comparison.
+user_eq_dummy.m:014:   Discriminated unions whose body consists of a single
+user_eq_dummy.m:014:   zero-arity constructor cannot have user-defined equality
+user_eq_dummy.m:014:   or comparison.
Index: tests/invalid/with_type.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/with_type.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 with_type.err_exp
--- tests/invalid/with_type.err_exp	7 Mar 2006 01:03:46 -0000	1.4
+++ tests/invalid/with_type.err_exp	5 Sep 2006 12:08:54 -0000
@@ -13,5 +13,5 @@
 with_type.m:021: In type declaration for predicate `with_type.with_type_3':
 with_type.m:021:   error: the `with_type` and `with_inst` annotations are
 with_type.m:021:   incompatible.
-with_type.m:019: Error: mode declaration for function `with_type.with_type_2/3'
+with_type.m:019: Error: mode declaration for function `with_type.with_type_2'/3
 with_type.m:019:   without preceding `func' declaration.
cvs diff: Diffing tests/invalid/purity
Index: tests/invalid/purity/impure_func_t2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/impure_func_t2.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 impure_func_t2.err_exp
--- tests/invalid/purity/impure_func_t2.err_exp	14 Sep 2005 05:27:09 -0000	1.4
+++ tests/invalid/purity/impure_func_t2.err_exp	5 Sep 2006 12:09:05 -0000
@@ -1,4 +1,4 @@
 impure_func_t2.m:016: In call to impure function
-impure_func_t2.m:016:   `impure_func_t2.get_counter/0':
+impure_func_t2.m:016:   `impure_func_t2.get_counter'/0:
 impure_func_t2.m:016:   purity error: call must be in an explicit unification
 impure_func_t2.m:016:   which is preceded by `impure' indicator.
Index: tests/invalid/purity/impure_func_t3.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/impure_func_t3.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 impure_func_t3.err_exp
--- tests/invalid/purity/impure_func_t3.err_exp	14 Sep 2005 05:27:09 -0000	1.4
+++ tests/invalid/purity/impure_func_t3.err_exp	5 Sep 2006 12:09:06 -0000
@@ -1,7 +1,7 @@
 impure_func_t3.m:017: In call to impure function
-impure_func_t3.m:017:   `impure_func_t3.get_counter/0':
+impure_func_t3.m:017:   `impure_func_t3.get_counter'/0:
 impure_func_t3.m:017:   purity error: call must be in an explicit unification
 impure_func_t3.m:017:   which is preceded by `impure' indicator.
-impure_func_t3.m:017: In call to predicate `io.print/3':
+impure_func_t3.m:017: In call to predicate `io.print'/3:
 impure_func_t3.m:017:   warning: unnecessary `impure' indicator.
 impure_func_t3.m:017:   No purity indicator is necessary.
Index: tests/invalid/purity/impure_func_t4.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/impure_func_t4.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 impure_func_t4.err_exp
--- tests/invalid/purity/impure_func_t4.err_exp	14 Sep 2005 05:27:09 -0000	1.4
+++ tests/invalid/purity/impure_func_t4.err_exp	5 Sep 2006 12:09:06 -0000
@@ -1,4 +1,4 @@
 impure_func_t4.m:017: In call to semipure function
-impure_func_t4.m:017:   `impure_func_t4.get_counter/0':
+impure_func_t4.m:017:   `impure_func_t4.get_counter'/0:
 impure_func_t4.m:017:   purity error: call must be in an explicit unification
 impure_func_t4.m:017:   which is preceded by `semipure' indicator.
Index: tests/invalid/purity/impure_func_t5.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/impure_func_t5.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 impure_func_t5.err_exp
--- tests/invalid/purity/impure_func_t5.err_exp	14 Jun 2006 08:15:00 -0000	1.5
+++ tests/invalid/purity/impure_func_t5.err_exp	6 Sep 2006 14:43:36 -0000
@@ -1,12 +1,12 @@
-impure_func_t5.m:018: In clause for predicate `impure_func_t5.main/2':
+impure_func_t5.m:018: In clause for predicate `main'/2:
 impure_func_t5.m:018:   in argument 1 of functor `foo/1':
 impure_func_t5.m:018:   type error in unification of argument
 impure_func_t5.m:018:   and constant `get_counter'.
 impure_func_t5.m:018:   argument has type `((func int) = int)',
-impure_func_t5.m:018:   constant `get_counter' has type `(impure ((func int) = int))'.
-	The partial type assignment was:
-	Y_3: (impure_func_t5.foo)
-	DCG_0_5: (io.state)
-	DCG_3_8: (io.state)
-	V_9: ((func int) = int)
-
+impure_func_t5.m:018:   constant `get_counter' has type `(impure ((func int) =
+impure_func_t5.m:018:   int))'.
+impure_func_t5.m:018:   The partial type assignment was:
+impure_func_t5.m:018:     Y_3: (impure_func_t5.foo)
+impure_func_t5.m:018:     DCG_0_5: (io.state)
+impure_func_t5.m:018:     DCG_3_8: (io.state)
+impure_func_t5.m:018:     V_9: ((func int) = int)
Index: tests/invalid/purity/impure_func_t5_fixed.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/impure_func_t5_fixed.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 impure_func_t5_fixed.err_exp
--- tests/invalid/purity/impure_func_t5_fixed.err_exp	14 Jun 2006 08:15:00 -0000	1.5
+++ tests/invalid/purity/impure_func_t5_fixed.err_exp	5 Sep 2006 12:09:07 -0000
@@ -6,4 +6,3 @@
 impure_func_t5_fixed.m:022:   expected instantiatedness was `ground'.
 impure_func_t5_fixed.m:022:   The goal could not be reordered, because it was
 impure_func_t5_fixed.m:022:   impure.
-For more information, recompile with `-E'.
Index: tests/invalid/purity/impure_pred_t1.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/impure_pred_t1.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 impure_pred_t1.err_exp
--- tests/invalid/purity/impure_pred_t1.err_exp	14 Jun 2006 08:15:00 -0000	1.5
+++ tests/invalid/purity/impure_pred_t1.err_exp	6 Sep 2006 14:43:41 -0000
@@ -1,12 +1,12 @@
-impure_pred_t1.m:020: In clause for predicate `impure_pred_t1.main/2':
+impure_pred_t1.m:020: In clause for predicate `main'/2:
 impure_pred_t1.m:020:   in argument 1 of functor `foo/1':
 impure_pred_t1.m:020:   type error in unification of argument
 impure_pred_t1.m:020:   and constant `get_counter'.
 impure_pred_t1.m:020:   argument has type `pred(int, int)',
-impure_pred_t1.m:020:   constant `get_counter' has type `(impure pred(int, int))'.
-	The partial type assignment was:
-	Y_3: (impure_pred_t1.foo)
-	DCG_0_6: (io.state)
-	DCG_3_9: (io.state)
-	V_10: pred(int, int)
-
+impure_pred_t1.m:020:   constant `get_counter' has type `(impure pred(int,
+impure_pred_t1.m:020:   int))'.
+impure_pred_t1.m:020:   The partial type assignment was:
+impure_pred_t1.m:020:     Y_3: (impure_pred_t1.foo)
+impure_pred_t1.m:020:     DCG_0_6: (io.state)
+impure_pred_t1.m:020:     DCG_3_9: (io.state)
+impure_pred_t1.m:020:     V_10: pred(int, int)
Index: tests/invalid/purity/impure_pred_t1_fixed.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/impure_pred_t1_fixed.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 impure_pred_t1_fixed.err_exp
--- tests/invalid/purity/impure_pred_t1_fixed.err_exp	14 Jun 2006 08:15:00 -0000	1.3
+++ tests/invalid/purity/impure_pred_t1_fixed.err_exp	6 Sep 2006 14:43:41 -0000
@@ -1,12 +1,13 @@
-impure_pred_t1_fixed.m:022: In clause for predicate `impure_pred_t1_fixed.main/2':
-impure_pred_t1_fixed.m:022:   in argument 1 (i.e. the predicate term) of higher-order predicate call:
-impure_pred_t1_fixed.m:022:   type error: variable `X' has type `(impure pred(int, int))',
+impure_pred_t1_fixed.m:022: In clause for predicate `main'/2:
+impure_pred_t1_fixed.m:022:   in argument 1 (i.e. the predicate term) of
+impure_pred_t1_fixed.m:022:   higher-order predicate call:
+impure_pred_t1_fixed.m:022:   type error: variable `X' has type `(impure
+impure_pred_t1_fixed.m:022:   pred(int, int))',
 impure_pred_t1_fixed.m:022:   expected type was `pred(V_2, V_1)'.
-	The partial type assignment was:
-	Y_3: (impure_pred_t1_fixed.foo)
-	X_4: (impure pred(int, int))
-	DCG_0_6: (io.state)
-	DCG_3_9: (io.state)
-	V_10: (impure pred(int, int))
-	V_11: int
-
+impure_pred_t1_fixed.m:022:   The partial type assignment was:
+impure_pred_t1_fixed.m:022:     Y_3: (impure_pred_t1_fixed.foo)
+impure_pred_t1_fixed.m:022:     X_4: (impure pred(int, int))
+impure_pred_t1_fixed.m:022:     DCG_0_6: (io.state)
+impure_pred_t1_fixed.m:022:     DCG_3_9: (io.state)
+impure_pred_t1_fixed.m:022:     V_10: (impure pred(int, int))
+impure_pred_t1_fixed.m:022:     V_11: int
Index: tests/invalid/purity/impure_pred_t2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/impure_pred_t2.err_exp,v
retrieving revision 1.5
diff -u -b -r1.5 impure_pred_t2.err_exp
--- tests/invalid/purity/impure_pred_t2.err_exp	14 Jun 2006 08:15:00 -0000	1.5
+++ tests/invalid/purity/impure_pred_t2.err_exp	6 Sep 2006 14:43:42 -0000
@@ -1,10 +1,11 @@
-impure_pred_t2.m:019: In clause for predicate `impure_pred_t2.main/2':
-impure_pred_t2.m:019:   in argument 1 (i.e. the predicate term) of higher-order predicate call:
-impure_pred_t2.m:019:   type error: variable `Y' has type `(impure pred(int, int))',
+impure_pred_t2.m:019: In clause for predicate `main'/2:
+impure_pred_t2.m:019:   in argument 1 (i.e. the predicate term) of higher-order
+impure_pred_t2.m:019:   predicate call:
+impure_pred_t2.m:019:   type error: variable `Y' has type `(impure pred(int,
+impure_pred_t2.m:019:   int))',
 impure_pred_t2.m:019:   expected type was `pred(V_2, V_1)'.
-	The partial type assignment was:
-	Y_3: (impure pred(int, int))
-	DCG_0_5: (io.state)
-	DCG_3_8: (io.state)
-	V_9: int
-
+impure_pred_t2.m:019:   The partial type assignment was:
+impure_pred_t2.m:019:     Y_3: (impure pred(int, int))
+impure_pred_t2.m:019:     DCG_0_5: (io.state)
+impure_pred_t2.m:019:     DCG_3_8: (io.state)
+impure_pred_t2.m:019:     V_9: int
Index: tests/invalid/purity/purity.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/purity.err_exp,v
retrieving revision 1.12
diff -u -b -r1.12 purity.err_exp
--- tests/invalid/purity/purity.err_exp	10 Jul 2006 04:40:58 -0000	1.12
+++ tests/invalid/purity/purity.err_exp	5 Sep 2006 12:09:12 -0000
@@ -1,33 +1,33 @@
-purity.m:050: In predicate `purity.w1/0':
+purity.m:050: In predicate `purity.w1'/0:
 purity.m:050:   warning: declared impure but actually pure.
-purity.m:054: In predicate `purity.w2/0':
+purity.m:054: In predicate `purity.w2'/0:
 purity.m:054:   warning: declared semipure but actually pure.
-purity.m:058: In predicate `purity.w3/0':
+purity.m:058: In predicate `purity.w3'/0:
 purity.m:058:   warning: declared impure but actually semipure.
-purity.m:062: In predicate `purity.w4/0':
+purity.m:062: In predicate `purity.w4'/0:
 purity.m:062:   warning: unnecessary `promise_pure' pragma.
-purity.m:067: In predicate `purity.w5/0':
+purity.m:067: In predicate `purity.w5'/0:
 purity.m:067:   error: declared impure but promised pure.
-purity.m:072: In predicate `purity.w6/0':
+purity.m:072: In predicate `purity.w6'/0:
 purity.m:072:   error: declared semipure but promised pure.
-purity.m:081: In predicate `purity.e1/0':
+purity.m:081: In predicate `purity.e1'/0:
 purity.m:081:   purity error: predicate is impure.
 purity.m:081:   It must be declared `impure' or promised pure.
-purity.m:086: In predicate `purity.e2/0':
+purity.m:086: In predicate `purity.e2'/0:
 purity.m:086:   purity error: predicate is semipure.
 purity.m:086:   It must be declared `semipure' or promised pure.
-purity.m:090: In predicate `purity.e3/0':
+purity.m:090: In predicate `purity.e3'/0:
 purity.m:090:   purity error: predicate is impure.
 purity.m:090:   It must be declared `impure' or promised semipure.
-purity.m:096: In call to impure predicate `purity.imp/0':
+purity.m:096: In call to impure predicate `purity.imp'/0:
 purity.m:096:   purity error: call must be preceded by `impure' indicator.
-purity.m:100: In call to semipure predicate `purity.semi/0':
+purity.m:100: In call to semipure predicate `purity.semi'/0:
 purity.m:100:   purity error: call must be preceded by `semipure' indicator.
-purity.m:142: In call to impure predicate `purity.imp1/1':
+purity.m:142: In call to impure predicate `purity.imp1'/1:
 purity.m:142:   purity error: call must be preceded by `impure' indicator.
 purity.m:142: Purity error in closure: closure body is impure, but closure was
 purity.m:142:   not declared impure.
-purity.m:148: In call to semipure predicate `purity.semi/1':
+purity.m:148: In call to semipure predicate `purity.semi'/1:
 purity.m:148:   purity error: call must be preceded by `semipure' indicator.
 purity.m:148: Purity error in closure: closure body is semipure, but closure
 purity.m:148:   was not declared semipure.
@@ -38,14 +38,14 @@
 purity.m:127:   purity error: predicate is semipure.
 purity.m:127:   It must be pure.
 purity.m:105: In clause for `e6':
-purity.m:105:   in argument 1 of call to predicate `purity.in/1':
+purity.m:105:   in argument 1 of call to predicate `purity.in'/1:
 purity.m:105:   mode error: variable `X' has instantiatedness `free',
 purity.m:105:   expected instantiatedness was `ground'.
 purity.m:105:   The goal could not be reordered, because it was followed by an
 purity.m:105:   impure goal.
 purity.m:106:   This is the location of the impure goal.
 purity.m:112: In clause for `e7':
-purity.m:112:   in argument 1 of call to predicate `purity.imp1/1':
+purity.m:112:   in argument 1 of call to predicate `purity.imp1'/1:
 purity.m:112:   mode error: variable `X' has instantiatedness `free',
 purity.m:112:   expected instantiatedness was `ground'.
 purity.m:112:   The goal could not be reordered, because it was impure.
Index: tests/invalid/purity/purity_nonsense.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/purity_nonsense.err_exp,v
retrieving revision 1.8
diff -u -b -r1.8 purity_nonsense.err_exp
--- tests/invalid/purity/purity_nonsense.err_exp	14 Jun 2006 08:15:00 -0000	1.8
+++ tests/invalid/purity/purity_nonsense.err_exp	5 Sep 2006 12:09:13 -0000
@@ -1,41 +1,42 @@
-purity_nonsense.m:012: Error: clause for predicate `purity_nonsense.e12/0'
+purity_nonsense.m:012: Error: clause for predicate `purity_nonsense.e12'/0
 purity_nonsense.m:012:   without preceding `pred' declaration.
-purity_nonsense.m:013: Error: clause for predicate `purity_nonsense.e13/0'
+purity_nonsense.m:013: Error: clause for predicate `purity_nonsense.e13'/0
 purity_nonsense.m:013:   without preceding `pred' declaration.
-purity_nonsense.m:018: In clause for predicate `purity_nonsense.e14/1':
-purity_nonsense.m:018:   in argument 1 (i.e. the predicate term) of impure higher-order predicate call:
+purity_nonsense.m:018: In clause for predicate `e14'/1:
+purity_nonsense.m:018:   in argument 1 (i.e. the predicate term) of impure
+purity_nonsense.m:018:   higher-order predicate call:
 purity_nonsense.m:018:   type error: variable `P' has type `(pred)',
 purity_nonsense.m:018:   expected type was `(impure (pred))'.
-purity_nonsense.m:012: In clause for predicate `purity_nonsense.e12/0':
-purity_nonsense.m:012:   in argument 1 of call to predicate `impure/1':
-purity_nonsense.m:012:   error: the language construct \\+/1 should be
-purity_nonsense.m:012:   used as a goal, not as an expression.
-purity_nonsense.m:012: In clause for predicate `purity_nonsense.e12/0':
-purity_nonsense.m:012:   in argument 1 of call to predicate `impure/1':
+purity_nonsense.m:012: In clause for predicate `e12'/0:
+purity_nonsense.m:012:   in argument 1 of call to predicate `impure'/1:
+purity_nonsense.m:012:   error: the language construct `\+'/1 should be used as
+purity_nonsense.m:012:   a goal, not as an expression.
+purity_nonsense.m:012: In clause for predicate `e12'/0:
+purity_nonsense.m:012:   in argument 1 of call to predicate `impure'/1:
 purity_nonsense.m:012:   in argument 1 of functor `\\+/1':
-purity_nonsense.m:012:   error: the language construct impure/1 should be
+purity_nonsense.m:012:   error: the language construct `impure'/1 should be
 purity_nonsense.m:012:   used as a goal, not as an expression.
-purity_nonsense.m:012: In clause for predicate `purity_nonsense.e12/0':
-purity_nonsense.m:012:   in argument 1 of call to predicate `impure/1':
+purity_nonsense.m:012: In clause for predicate `e12'/0:
+purity_nonsense.m:012:   in argument 1 of call to predicate `impure'/1:
 purity_nonsense.m:012:   in argument 1 of functor `\\+/1':
 purity_nonsense.m:012:   in argument 1 of functor `impure/1':
 purity_nonsense.m:012:   error: undefined symbol `imp/0'.
-purity_nonsense.m:012: In clause for predicate `purity_nonsense.e12/0':
+purity_nonsense.m:012: In clause for predicate `e12'/0:
 purity_nonsense.m:012:   error: `impure' marker in an inappropriate place.
-purity_nonsense.m:013: In clause for predicate `purity_nonsense.e13/0':
-purity_nonsense.m:013:   in argument 1 of call to predicate `semipure/1':
-purity_nonsense.m:013:   error: the language construct \\+/1 should be
-purity_nonsense.m:013:   used as a goal, not as an expression.
-purity_nonsense.m:013: In clause for predicate `purity_nonsense.e13/0':
-purity_nonsense.m:013:   in argument 1 of call to predicate `semipure/1':
+purity_nonsense.m:013: In clause for predicate `e13'/0:
+purity_nonsense.m:013:   in argument 1 of call to predicate `semipure'/1:
+purity_nonsense.m:013:   error: the language construct `\+'/1 should be used as
+purity_nonsense.m:013:   a goal, not as an expression.
+purity_nonsense.m:013: In clause for predicate `e13'/0:
+purity_nonsense.m:013:   in argument 1 of call to predicate `semipure'/1:
 purity_nonsense.m:013:   in argument 1 of functor `\\+/1':
-purity_nonsense.m:013:   error: the language construct semipure/1 should be
+purity_nonsense.m:013:   error: the language construct `semipure'/1 should be
 purity_nonsense.m:013:   used as a goal, not as an expression.
-purity_nonsense.m:013: In clause for predicate `purity_nonsense.e13/0':
-purity_nonsense.m:013:   in argument 1 of call to predicate `semipure/1':
+purity_nonsense.m:013: In clause for predicate `e13'/0:
+purity_nonsense.m:013:   in argument 1 of call to predicate `semipure'/1:
 purity_nonsense.m:013:   in argument 1 of functor `\\+/1':
 purity_nonsense.m:013:   in argument 1 of functor `semipure/1':
 purity_nonsense.m:013:   error: undefined symbol `semi/0'.
-purity_nonsense.m:013: In clause for predicate `purity_nonsense.e13/0':
+purity_nonsense.m:013: In clause for predicate `e13'/0:
 purity_nonsense.m:013:   error: `semipure' marker in an inappropriate place.
 For more information, recompile with `-E'.
Index: tests/invalid/purity/purity_nonsense2.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/purity_nonsense2.err_exp,v
retrieving revision 1.4
diff -u -b -r1.4 purity_nonsense2.err_exp
--- tests/invalid/purity/purity_nonsense2.err_exp	14 Sep 2005 05:27:10 -0000	1.4
+++ tests/invalid/purity/purity_nonsense2.err_exp	5 Sep 2006 12:09:14 -0000
@@ -3,7 +3,7 @@
 purity_nonsense2.m:010: Error: `:- pragma promise_pure' declaration for
 purity_nonsense2.m:010:   `purity_nonsense2.undefined2'/0 without corresponding
 purity_nonsense2.m:010:   `pred' or `func' declaration.
-purity_nonsense2.m:012: Error: clause for predicate `purity_nonsense2.e12/0'
+purity_nonsense2.m:012: Error: clause for predicate `purity_nonsense2.e12'/0
 purity_nonsense2.m:012:   without preceding `pred' declaration.
-purity_nonsense2.m:013: Error: clause for predicate `purity_nonsense2.e13/0'
+purity_nonsense2.m:013: Error: clause for predicate `purity_nonsense2.e13'/0
 purity_nonsense2.m:013:   without preceding `pred' declaration.
Index: tests/invalid/purity/purity_type_error.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/purity/purity_type_error.err_exp,v
retrieving revision 1.6
diff -u -b -r1.6 purity_type_error.err_exp
--- tests/invalid/purity/purity_type_error.err_exp	14 Jun 2006 08:15:00 -0000	1.6
+++ tests/invalid/purity/purity_type_error.err_exp	6 Sep 2006 14:43:47 -0000
@@ -1,11 +1,10 @@
-purity_type_error.m:020: In clause for predicate `purity_type_error.type_error/1':
+purity_type_error.m:020: In clause for predicate `type_error'/1:
 purity_type_error.m:020:   in argument 1 of clause head:
 purity_type_error.m:020:   type error in unification of variable `HeadVar__1'
 purity_type_error.m:020:   and constant `1.00000000000000'.
 purity_type_error.m:020:   variable `HeadVar__1' has type `int',
 purity_type_error.m:020:   constant `1.00000000000000' has type `float'.
-	The partial type assignment was:
-	HeadVar__1_1: int
-
-purity_type_error.m:009: In predicate `purity_type_error.warn/1':
+purity_type_error.m:020:   The partial type assignment was:
+purity_type_error.m:020:     HeadVar__1_1: int
+purity_type_error.m:009: In predicate `purity_type_error.warn'/1:
 purity_type_error.m:009:   warning: declared impure but actually pure.
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
Index: tests/recompilation/add_instance_2_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/add_instance_2_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 add_instance_2_r.err_exp.2
--- tests/recompilation/add_instance_2_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/add_instance_2_r.err_exp.2	5 Sep 2006 16:37:08 -0000
@@ -1,3 +1,3 @@
 Recompiling module `add_instance_2_r':
-  an instance for class `add_instance_2_r.io/1' in module `add_instance_2_r_2'
+  an instance for class `add_instance_2_r.io'/1 in module `add_instance_2_r_2'
   was added or modified.
Index: tests/recompilation/add_instance_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/add_instance_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 add_instance_r.err_exp.2
--- tests/recompilation/add_instance_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/add_instance_r.err_exp.2	5 Sep 2006 16:37:01 -0000
@@ -1,3 +1,3 @@
 Recompiling module `add_instance_r':
-  an instance for class `add_instance_r_2.io/1' in module `add_instance_r_2'
+  an instance for class `add_instance_r_2.io'/1 in module `add_instance_r_2'
   was added or modified.
Index: tests/recompilation/add_type_re.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/add_type_re.err_exp.2,v
retrieving revision 1.5
diff -u -b -r1.5 add_type_re.err_exp.2
--- tests/recompilation/add_type_re.err_exp.2	14 Jun 2006 08:15:01 -0000	1.5
+++ tests/recompilation/add_type_re.err_exp.2	5 Sep 2006 16:39:55 -0000
@@ -1,6 +1,6 @@
 Recompiling module `add_type_re':
-  addition of type `add_type_re_2.bar/0' could cause an ambiguity with type
-  `add_type_re.bar/0'.
+  addition of type `add_type_re_2.bar'/0 could cause an ambiguity with type
+  `add_type_re.bar'/0.
 add_type_re.m:029: In definition of predicate `add_type_re.output_bar'/3
 add_type_re.m:029:   ambiguity error: multiple possible matches for type
 add_type_re.m:029:   `bar'/0.
Index: tests/recompilation/change_class_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/change_class_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 change_class_r.err_exp.2
--- tests/recompilation/change_class_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/change_class_r.err_exp.2	5 Sep 2006 16:37:21 -0000
@@ -1,2 +1,2 @@
 Recompiling module `change_class_r':
-  typeclass `change_class_r_2.io/1' was modified.
+  typeclass `change_class_r_2.io'/1 was modified.
Index: tests/recompilation/change_func_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/change_func_r.err_exp.2,v
retrieving revision 1.3
diff -u -b -r1.3 change_func_r.err_exp.2
--- tests/recompilation/change_func_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.3
+++ tests/recompilation/change_func_r.err_exp.2	5 Sep 2006 16:37:27 -0000
@@ -1,4 +1,4 @@
 Recompiling module `change_func_r':
-  function `change_func_r_2.changed_func/1' was modified.
+  function `change_func_r_2.changed_func'/1 was modified.
 Recompiling module `change_func_r':
-  function `change_func_r_2.changed_func_2/1' was modified.
+  function `change_func_r_2.changed_func_2'/1 was modified.
Index: tests/recompilation/change_instance_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/change_instance_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 change_instance_r.err_exp.2
--- tests/recompilation/change_instance_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/change_instance_r.err_exp.2	5 Sep 2006 16:37:34 -0000
@@ -1,2 +1,2 @@
 Recompiling module `change_instance_r':
-  type `change_instance_r_2.baz/0' was modified.
+  type `change_instance_r_2.baz'/0 was modified.
Index: tests/recompilation/change_mode_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/change_mode_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 change_mode_r.err_exp.2
--- tests/recompilation/change_mode_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/change_mode_r.err_exp.2	5 Sep 2006 16:37:41 -0000
@@ -1,2 +1,2 @@
 Recompiling module `change_mode_r':
-  inst `change_mode_r_2.foo/0' was modified.
+  inst `change_mode_r_2.foo'/0 was modified.
Index: tests/recompilation/lambda_mode_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/lambda_mode_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 lambda_mode_r.err_exp.2
--- tests/recompilation/lambda_mode_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/lambda_mode_r.err_exp.2	5 Sep 2006 16:38:24 -0000
@@ -1,2 +1,2 @@
 Recompiling module `lambda_mode_r':
-  mode `lambda_mode_r_2.foo_in/0' was modified.
+  mode `lambda_mode_r_2.foo_in'/0 was modified.
Index: tests/recompilation/pragma_type_spec_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/pragma_type_spec_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 pragma_type_spec_r.err_exp.2
--- tests/recompilation/pragma_type_spec_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/pragma_type_spec_r.err_exp.2	5 Sep 2006 16:38:38 -0000
@@ -1,2 +1,2 @@
 Recompiling module `pragma_type_spec_r':
-  type `pragma_type_spec_r_2.foo/0' was modified.
+  type `pragma_type_spec_r_2.foo'/0 was modified.
Index: tests/recompilation/pred_overloading_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/pred_overloading_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 pred_overloading_r.err_exp.2
--- tests/recompilation/pred_overloading_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/pred_overloading_r.err_exp.2	5 Sep 2006 16:38:53 -0000
@@ -1,3 +1,3 @@
 Recompiling module `pred_overloading_r':
-  addition of predicate `pred_overloading_r_2.p/3' could cause an ambiguity
-  with predicate `pred_overloading_r.p/3'.
+  addition of predicate `pred_overloading_r_2.p'/3 could cause an ambiguity
+  with predicate `pred_overloading_r.p'/3.
Index: tests/recompilation/remove_type_re.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/remove_type_re.err_exp.2,v
retrieving revision 1.4
diff -u -b -r1.4 remove_type_re.err_exp.2
--- tests/recompilation/remove_type_re.err_exp.2	14 Sep 2005 05:27:11 -0000	1.4
+++ tests/recompilation/remove_type_re.err_exp.2	5 Sep 2006 16:40:02 -0000
@@ -1,6 +1,6 @@
 Recompiling module `remove_type_re':
-  type `remove_type_re_2.foo/0' was removed.
+  type `remove_type_re_2.foo'/0 was removed.
 Recompiling module `remove_type_re':
-  body of type `remove_type_re_2.foo/0' was removed.
+  body of type `remove_type_re_2.foo'/0 was removed.
 remove_type_re.m:016: In definition of predicate `remove_type_re.output_foo'/3:
 remove_type_re.m:016:   error: undefined type `foo'/0.
Index: tests/recompilation/type_qual_re.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/type_qual_re.err_exp.2,v
retrieving revision 1.3
diff -u -b -r1.3 type_qual_re.err_exp.2
--- tests/recompilation/type_qual_re.err_exp.2	14 Sep 2005 05:27:11 -0000	1.3
+++ tests/recompilation/type_qual_re.err_exp.2	5 Sep 2006 16:40:09 -0000
@@ -1,4 +1,4 @@
 Recompiling module `type_qual_re':
-  type `type_qual_re_2.bar/0' was removed.
+  type `type_qual_re_2.bar'/0 was removed.
 type_qual_re.m:016: In explicit type qualification:
 type_qual_re.m:016:   error: undefined type `bar'/0.
Index: tests/recompilation/type_spec_rename_var_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/type_spec_rename_var_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 type_spec_rename_var_r.err_exp.2
--- tests/recompilation/type_spec_rename_var_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/type_spec_rename_var_r.err_exp.2	5 Sep 2006 16:39:07 -0000
@@ -1,2 +1,2 @@
 Recompiling module `type_spec_rename_var_r':
-  predicate `type_spec_rename_var_r_2.p/3' was modified.
+  predicate `type_spec_rename_var_r_2.p'/3 was modified.
Index: tests/recompilation/type_spec_unname_var_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/type_spec_unname_var_r.err_exp.2,v
retrieving revision 1.2
diff -u -b -r1.2 type_spec_unname_var_r.err_exp.2
--- tests/recompilation/type_spec_unname_var_r.err_exp.2	18 Jan 2003 17:02:10 -0000	1.2
+++ tests/recompilation/type_spec_unname_var_r.err_exp.2	5 Sep 2006 16:39:15 -0000
@@ -1,2 +1,2 @@
 Recompiling module `type_spec_unname_var_r':
-  predicate `type_spec_unname_var_r_2.p/4' was modified.
+  predicate `type_spec_unname_var_r_2.p'/4 was modified.
Index: tests/recompilation/typeclass_method_pragma_r.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/typeclass_method_pragma_r.err_exp.2,v
retrieving revision 1.5
diff -u -b -r1.5 typeclass_method_pragma_r.err_exp.2
--- tests/recompilation/typeclass_method_pragma_r.err_exp.2	16 Jan 2006 03:08:17 -0000	1.5
+++ tests/recompilation/typeclass_method_pragma_r.err_exp.2	5 Sep 2006 16:39:00 -0000
@@ -1,5 +1,5 @@
 Recompiling module `typeclass_method_pragma_r':
-  typeclass `typeclass_method_pragma_r_2.io/1' was modified.
+  typeclass `typeclass_method_pragma_r_2.io'/1 was modified.
 typeclass_method_pragma_r.m:015: Warning: call to obsolete type class predicate
 typeclass_method_pragma_r.m:015:   method
-typeclass_method_pragma_r.m:015:   `typeclass_method_pragma_r_2.output/3'.
+typeclass_method_pragma_r.m:015:   `typeclass_method_pragma_r_2.output'/3.
Index: tests/recompilation/with_type_re.err_exp.2
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/recompilation/with_type_re.err_exp.2,v
retrieving revision 1.3
diff -u -b -r1.3 with_type_re.err_exp.2
--- tests/recompilation/with_type_re.err_exp.2	14 Sep 2005 05:27:11 -0000	1.3
+++ tests/recompilation/with_type_re.err_exp.2	5 Sep 2006 16:40:16 -0000
@@ -1,12 +1,12 @@
 Recompiling module `with_type_re':
-  type `with_type_re_2.map_pred/2' was modified.
+  type `with_type_re_2.map_pred'/2 was modified.
 Recompiling module `with_type_re':
-  inst `with_type_re_2.map_pred/0' was modified.
+  inst `with_type_re_2.map_pred'/0 was modified.
 Recompiling module `with_type_re':
-  function `with_type_re_2.with_type_2/2' was modified.
+  function `with_type_re_2.with_type_2'/2 was modified.
 Recompiling module `with_type_re':
-  addition of predicate `with_type_re_2.with_type_3/4' could cause an ambiguity
-  with predicate `with_type_re.with_type_3/4'.
-with_type_re.m:015: In clause for predicate `with_type_re.main/2':
+  addition of predicate `with_type_re_2.with_type_3'/4 could cause an ambiguity
+  with predicate `with_type_re.with_type_3'/4.
+with_type_re.m:015: In clause for predicate `main'/2:
 with_type_re.m:015:   error: wrong number of arguments (4; should be 5)
 with_type_re.m:015:   in call to predicate `with_type_1'.
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
Index: tests/warnings/ambiguous_overloading.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/ambiguous_overloading.exp,v
retrieving revision 1.5
diff -u -b -r1.5 ambiguous_overloading.exp
--- tests/warnings/ambiguous_overloading.exp	31 Jul 2006 03:19:29 -0000	1.5
+++ tests/warnings/ambiguous_overloading.exp	5 Sep 2006 12:22:45 -0000
@@ -1,4 +1,4 @@
-ambiguous_overloading.m:041: In clause for predicate `ambig_overload1/1':
+ambiguous_overloading.m:041: In clause for predicate `ambig_overload1'/1:
 ambiguous_overloading.m:041:   warning: highly ambiguous overloading.
 ambiguous_overloading.m:041:   The following symbol was overloaded in the
 ambiguous_overloading.m:041:   following context.
@@ -9,7 +9,7 @@
 ambiguous_overloading.m:041:     the type constructor
 ambiguous_overloading.m:041:     `ambiguous_overloading.bar'/0,
 ambiguous_overloading.m:041:     the builtin type constructor `character'.
-ambiguous_overloading.m:045: In clause for predicate `ambig_overload2/1':
+ambiguous_overloading.m:045: In clause for predicate `ambig_overload2'/1:
 ambiguous_overloading.m:045:   warning: highly ambiguous overloading.
 ambiguous_overloading.m:045:   The following symbols were overloaded in the
 ambiguous_overloading.m:045:   following contexts.
@@ -25,29 +25,30 @@
 ambiguous_overloading.m:045:     `ambiguous_overloading.qux'/0,
 ambiguous_overloading.m:045:     the type constructor
 ambiguous_overloading.m:045:     `ambiguous_overloading.baz'/0.
-ambiguous_overloading.m:055: In clause for predicate `test_lt/1': warning:
-ambiguous_overloading.m:055:   highly ambiguous overloading.
+ambiguous_overloading.m:055: In clause for predicate `test_lt'/1:
+ambiguous_overloading.m:055:   warning: highly ambiguous overloading.
 ambiguous_overloading.m:055:   The following symbol was overloaded in the
 ambiguous_overloading.m:055:   following contexts.
-ambiguous_overloading.m:050:   The predicate symbol predicate `</2'.
+ambiguous_overloading.m:050:   The predicate symbol predicate `<'/2.
 ambiguous_overloading.m:050:   The possible matches are:
-ambiguous_overloading.m:050:     predicate `float.</2',
-ambiguous_overloading.m:050:     predicate `int.</2'.
-ambiguous_overloading.m:051:   The predicate symbol predicate `</2' is also
+ambiguous_overloading.m:050:     predicate `float.<'/2,
+ambiguous_overloading.m:050:     predicate `int.<'/2.
+ambiguous_overloading.m:051:   The predicate symbol predicate `<'/2 is also
 ambiguous_overloading.m:051:   overloaded here.
-ambiguous_overloading.m:052:   The predicate symbol predicate `</2' is also
+ambiguous_overloading.m:052:   The predicate symbol predicate `<'/2 is also
 ambiguous_overloading.m:052:   overloaded here.
-ambiguous_overloading.m:053:   The predicate symbol predicate `</2' is also
+ambiguous_overloading.m:053:   The predicate symbol predicate `<'/2 is also
 ambiguous_overloading.m:053:   overloaded here.
-ambiguous_overloading.m:054:   The predicate symbol predicate `</2' is also
+ambiguous_overloading.m:054:   The predicate symbol predicate `<'/2 is also
 ambiguous_overloading.m:054:   overloaded here.
-ambiguous_overloading.m:055:   The predicate symbol predicate `</2' is also
+ambiguous_overloading.m:055:   The predicate symbol predicate `<'/2 is also
 ambiguous_overloading.m:055:   overloaded here.
-ambiguous_overloading.m:071: In clause for predicate `set_browser_param_from_option_table/3':
+ambiguous_overloading.m:071: In clause for predicate
+ambiguous_overloading.m:071:   `set_browser_param_from_option_table'/3:
 ambiguous_overloading.m:071:   warning: highly ambiguous overloading.
 ambiguous_overloading.m:071:   The following symbol was overloaded in the
 ambiguous_overloading.m:071:   following context.
 ambiguous_overloading.m:071:   The function symbol `lookup_bool_option'/2.
 ambiguous_overloading.m:071:   The possible matches are:
-ambiguous_overloading.m:071:     predicate `getopt.lookup_bool_option/3',
-ambiguous_overloading.m:071:     function `getopt.lookup_bool_option/2'.
+ambiguous_overloading.m:071:     predicate `getopt.lookup_bool_option'/3,
+ambiguous_overloading.m:071:     function `getopt.lookup_bool_option'/2.
Index: tests/warnings/arg_order_rearrangment.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/arg_order_rearrangment.exp,v
retrieving revision 1.4
diff -u -b -r1.4 arg_order_rearrangment.exp
--- tests/warnings/arg_order_rearrangment.exp	17 Jan 2003 05:57:19 -0000	1.4
+++ tests/warnings/arg_order_rearrangment.exp	5 Sep 2006 12:22:41 -0000
@@ -1,6 +1,6 @@
-arg_order_rearrangment.m:008: In predicate `arg_order_rearrangment.r/2'
+arg_order_rearrangment.m:008: In predicate `arg_order_rearrangment.r'/2
 arg_order_rearrangment.m:014:   warning: the call to predicate
-arg_order_rearrangment.m:014:     `arg_order_rearrangment.app/3' has had the
+arg_order_rearrangment.m:014:     `arg_order_rearrangment.app'/3 has had the
 arg_order_rearrangment.m:014:     location of the variables `V_7' and `R0'
 arg_order_rearrangment.m:014:     swapped to allow accumulator introduction.
 arg_order_rearrangment.m:008:   Please ensure that these argument
Index: tests/warnings/double_underscore.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/double_underscore.exp,v
retrieving revision 1.4
diff -u -b -r1.4 double_underscore.exp
--- tests/warnings/double_underscore.exp	8 Aug 2005 02:33:19 -0000	1.4
+++ tests/warnings/double_underscore.exp	5 Sep 2006 12:22:47 -0000
@@ -1,6 +1,6 @@
-double_underscore.m:011: In clause for predicate `double_underscore.p/2':
+double_underscore.m:011: In clause for predicate `double_underscore.p'/2:
 double_underscore.m:011:   warning: variable `_X' occurs more than once in this
 double_underscore.m:011:   scope.
-double_underscore.m:011: In clause for predicate `double_underscore.p/2':
+double_underscore.m:011: In clause for predicate `double_underscore.p'/2:
 double_underscore.m:011:   warning: variable `_X' occurs more than once in this
 double_underscore.m:011:   scope.
Index: tests/warnings/duplicate_call.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/duplicate_call.exp,v
retrieving revision 1.4
diff -u -b -r1.4 duplicate_call.exp
--- tests/warnings/duplicate_call.exp	17 Jan 2005 05:01:48 -0000	1.4
+++ tests/warnings/duplicate_call.exp	5 Sep 2006 12:22:47 -0000
@@ -1,4 +1,4 @@
 duplicate_call.m:015: Warning: redundant call to predicate
-duplicate_call.m:015:   `duplicate_call.called/3'.
+duplicate_call.m:015:   `duplicate_call.called'/3.
 duplicate_call.m:014: Here is the previous call to predicate
-duplicate_call.m:014:   `duplicate_call.called/3'.
+duplicate_call.m:014:   `duplicate_call.called'/3.
Index: tests/warnings/duplicate_const.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/duplicate_const.exp,v
retrieving revision 1.3
diff -u -b -r1.3 duplicate_const.exp
--- tests/warnings/duplicate_const.exp	17 Jan 2005 05:01:48 -0000	1.3
+++ tests/warnings/duplicate_const.exp	5 Sep 2006 12:22:48 -0000
@@ -1,4 +1,4 @@
 duplicate_const.m:016: Warning: redundant call to predicate
-duplicate_const.m:016:   `duplicate_const.called/4'.
+duplicate_const.m:016:   `duplicate_const.called'/4.
 duplicate_const.m:015: Here is the previous call to predicate
-duplicate_const.m:015:   `duplicate_const.called/4'.
+duplicate_const.m:015:   `duplicate_const.called'/4.
Index: tests/warnings/foreign_term_invalid.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/foreign_term_invalid.exp,v
retrieving revision 1.2
diff -u -b -r1.2 foreign_term_invalid.exp
--- tests/warnings/foreign_term_invalid.exp	17 Jan 2005 05:01:48 -0000	1.2
+++ tests/warnings/foreign_term_invalid.exp	5 Sep 2006 12:22:41 -0000
@@ -1,8 +1,8 @@
-foreign_term_invalid.m:009: Warning: predicate `foreign_term_invalid.test1/1'
+foreign_term_invalid.m:009: Warning: predicate `foreign_term_invalid.test1'/1
 foreign_term_invalid.m:009:   mode 0 has a `pragma does_not_terminate'
 foreign_term_invalid.m:009:   declaration but also has the `terminates' foreign
 foreign_term_invalid.m:009:   code attribute set.
-foreign_term_invalid.m:010: Warning: predicate `foreign_term_invalid.test2/1'
+foreign_term_invalid.m:010: Warning: predicate `foreign_term_invalid.test2'/1
 foreign_term_invalid.m:010:   mode 0 has a `pragma terminates' declaration but
 foreign_term_invalid.m:010:   also has the `does_not_terminate' foreign code
 foreign_term_invalid.m:010:   attribute set.
Index: tests/warnings/non_stratification.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/non_stratification.exp,v
retrieving revision 1.2
diff -u -b -r1.2 non_stratification.exp
--- tests/warnings/non_stratification.exp	28 Feb 2006 04:43:58 -0000	1.2
+++ tests/warnings/non_stratification.exp	5 Sep 2006 12:22:57 -0000
@@ -1,4 +1,4 @@
-non_stratification.m:012: In `foo(in)':
+non_stratification.m:012: In `foo'(in):
 non_stratification.m:012:   warning: call introduces a non-stratified loop.
 non_stratification.m:012:   A non-stratified loop is a loop in the call graph
 non_stratification.m:012:   of the given predicate/function that allows it to
Index: tests/warnings/pragma_source_file.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/pragma_source_file.exp,v
retrieving revision 1.5
diff -u -b -r1.5 pragma_source_file.exp
--- tests/warnings/pragma_source_file.exp	17 Jan 2003 05:57:19 -0000	1.5
+++ tests/warnings/pragma_source_file.exp	5 Sep 2006 12:22:58 -0000
@@ -1,4 +1,4 @@
-foo.m:002: In clause for predicate `pragma_source_file.my_append/3':
+foo.m:002: In clause for predicate `pragma_source_file.my_append'/3:
 foo.m:002:   warning: variable `L2' occurs only once in this scope.
-foo.m:011: In clause for predicate `pragma_source_file.my_append/3':
+foo.m:011: In clause for predicate `pragma_source_file.my_append'/3:
 foo.m:011:   warning: variable `X' occurs only once in this scope.
Index: tests/warnings/pragma_term_conflict.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/pragma_term_conflict.exp,v
retrieving revision 1.1
diff -u -b -r1.1 pragma_term_conflict.exp
--- tests/warnings/pragma_term_conflict.exp	25 Jun 2003 06:57:35 -0000	1.1
+++ tests/warnings/pragma_term_conflict.exp	5 Sep 2006 12:22:43 -0000
@@ -1,4 +1,4 @@
-pragma_term_conflict.m:008: Warning: predicate `pragma_term_conflict.a/0' and
-pragma_term_conflict.m:008:   predicate `pragma_term_conflict.b/0' are mutually
+pragma_term_conflict.m:008: Warning: predicate `pragma_term_conflict.a'/0 and
+pragma_term_conflict.m:008:   predicate `pragma_term_conflict.b'/0 are mutually
 pragma_term_conflict.m:008:   recursive but some of their termination pragmas
 pragma_term_conflict.m:008:   are inconsistent.
Index: tests/warnings/purity_warnings.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/purity_warnings.exp,v
retrieving revision 1.5
diff -u -b -r1.5 purity_warnings.exp
--- tests/warnings/purity_warnings.exp	6 Feb 2006 04:01:16 -0000	1.5
+++ tests/warnings/purity_warnings.exp	5 Sep 2006 12:22:59 -0000
@@ -1,25 +1,25 @@
-purity_warnings.m:021: In call to predicate `io.write_string/3':
+purity_warnings.m:021: In call to predicate `io.write_string'/3:
 purity_warnings.m:021:   warning: unnecessary `semipure' indicator.
 purity_warnings.m:021:   No purity indicator is necessary.
-purity_warnings.m:022: In call to predicate `io.print/3':
+purity_warnings.m:022: In call to predicate `io.print'/3:
 purity_warnings.m:022:   warning: unnecessary `impure' indicator.
 purity_warnings.m:022:   No purity indicator is necessary.
-purity_warnings.m:024: In predicate `purity_warnings.impure_pred1/2':
+purity_warnings.m:024: In predicate `purity_warnings.impure_pred1'/2:
 purity_warnings.m:024:   warning: declared impure but actually pure.
-purity_warnings.m:028: In predicate `purity_warnings.impure_pred2/2':
+purity_warnings.m:028: In predicate `purity_warnings.impure_pred2'/2:
 purity_warnings.m:028:   warning: declared impure but actually semipure.
-purity_warnings.m:036: In call to predicate `io.write_string/3':
+purity_warnings.m:036: In call to predicate `io.write_string'/3:
 purity_warnings.m:036:   warning: unnecessary `semipure' indicator.
 purity_warnings.m:036:   No purity indicator is necessary.
-purity_warnings.m:034: In predicate `purity_warnings.semipure_pred/2':
+purity_warnings.m:034: In predicate `purity_warnings.semipure_pred'/2:
 purity_warnings.m:034:   warning: declared semipure but actually pure.
-purity_warnings.m:065: In call to predicate `io.print/3':
+purity_warnings.m:065: In call to predicate `io.print'/3:
 purity_warnings.m:065:   warning: unnecessary `impure' indicator.
 purity_warnings.m:065:   No purity indicator is necessary.
-purity_warnings.m:060: In predicate `purity_warnings.impure_method1a_impl/2':
+purity_warnings.m:060: In predicate `purity_warnings.impure_method1a_impl'/2:
 purity_warnings.m:060:   warning: declared impure but actually pure.
-purity_warnings.m:071: In call to predicate `io.print/3':
+purity_warnings.m:071: In call to predicate `io.print'/3:
 purity_warnings.m:071:   warning: unnecessary `semipure' indicator.
 purity_warnings.m:071:   No purity indicator is necessary.
-purity_warnings.m:062: In predicate `purity_warnings.semipure_method_a_impl/2':
+purity_warnings.m:062: In predicate `purity_warnings.semipure_method_a_impl'/2:
 purity_warnings.m:062:   warning: declared semipure but actually pure.
Index: tests/warnings/simple_code.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/simple_code.exp,v
retrieving revision 1.14
diff -u -b -r1.14 simple_code.exp
--- tests/warnings/simple_code.exp	27 Jan 2006 05:52:27 -0000	1.14
+++ tests/warnings/simple_code.exp	5 Sep 2006 12:23:00 -0000
@@ -11,6 +11,6 @@
 simple_code.m:033: Warning: the negated goal cannot succeed.
 simple_code.m:035: Warning: the condition of this if-then-else cannot fail.
 simple_code.m:039: Warning: call to obsolete predicate
-simple_code.m:039:   `simple_code.obsolete/0'.
+simple_code.m:039:   `simple_code.obsolete'/0.
 simple_code.m:042: Warning: the condition of this if-then-else cannot fail.
 simple_code.m:099: Warning: recursive call will lead to infinite recursion.
Index: tests/warnings/singleton_test.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/singleton_test.exp,v
retrieving revision 1.11
diff -u -b -r1.11 singleton_test.exp
--- tests/warnings/singleton_test.exp	8 Aug 2005 02:33:19 -0000	1.11
+++ tests/warnings/singleton_test.exp	5 Sep 2006 12:23:01 -0000
@@ -1,18 +1,18 @@
-singleton_test.m:022: In clause for predicate `singleton_test.my_append/3':
+singleton_test.m:022: In clause for predicate `singleton_test.my_append'/3:
 singleton_test.m:022:   warning: variable `L2' occurs only once in this scope.
-singleton_test.m:026: In clause for function `singleton_test.my_append_func/2':
+singleton_test.m:026: In clause for function `singleton_test.my_append_func'/2:
 singleton_test.m:026:   warning: variables `L1, L2' occur only once in this
 singleton_test.m:026:   scope.
-singleton_test.m:027: In clause for function `singleton_test.my_append_func/2':
+singleton_test.m:027: In clause for function `singleton_test.my_append_func'/2:
 singleton_test.m:027:   warning: variable `T' occurs only once in this scope.
-singleton_test.m:029: In the C code for predicate `singleton_test.my_c_pred/3':
+singleton_test.m:029: In the C code for predicate `singleton_test.my_c_pred'/3:
 singleton_test.m:029:   warning: variable `Y' does not occur in the C code.
-singleton_test.m:041: In the C code for function `singleton_test.my_c_func/2':
+singleton_test.m:041: In the C code for function `singleton_test.my_c_func'/2:
 singleton_test.m:041:   warning: variable `X' does not occur in the C code.
 singleton_test.m:055: In the C code for predicate
-singleton_test.m:055:   `singleton_test.c_hello_world/3':
+singleton_test.m:055:   `singleton_test.c_hello_world'/3:
 singleton_test.m:055:   warning: variable `Msg' does not occur in the C code.
-singleton_test.m:008: In function `singleton_test.my_append_func/2':
+singleton_test.m:008: In function `singleton_test.my_append_func'/2:
 singleton_test.m:008:   warning: unresolved polymorphism.
 singleton_test.m:008:   The variables with unbound types were:
 singleton_test.m:008:       L2: V_1
Index: tests/warnings/spurious_obsolete.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/spurious_obsolete.exp,v
retrieving revision 1.1
diff -u -b -r1.1 spurious_obsolete.exp
--- tests/warnings/spurious_obsolete.exp	27 Mar 2006 06:56:22 -0000	1.1
+++ tests/warnings/spurious_obsolete.exp	5 Sep 2006 12:23:02 -0000
@@ -1,2 +1,2 @@
 spurious_obsolete.m:020: Warning: call to obsolete predicate
-spurious_obsolete.m:020:   `spurious_obsolete.foo/1'.
+spurious_obsolete.m:020:   `spurious_obsolete.foo'/1.
Index: tests/warnings/table_with_inline.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/table_with_inline.exp,v
retrieving revision 1.1
diff -u -b -r1.1 table_with_inline.exp
--- tests/warnings/table_with_inline.exp	5 Nov 2004 05:39:09 -0000	1.1
+++ tests/warnings/table_with_inline.exp	5 Sep 2006 12:23:05 -0000
@@ -1,4 +1,4 @@
-table_with_inline.m:011: Warning: function `table_with_inline.foo/1' has a
+table_with_inline.m:011: Warning: function `table_with_inline.foo'/1 has a
 table_with_inline.m:011:   `:- pragma memo' declaration but also has a
 table_with_inline.m:011:   `:- pragma inline' declaration.
 table_with_inline.m:011:   This inline pragma will be ignored since tabled
Index: tests/warnings/term_indirect_warning.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/term_indirect_warning.exp,v
retrieving revision 1.2
diff -u -b -r1.2 term_indirect_warning.exp
--- tests/warnings/term_indirect_warning.exp	17 Jan 2005 05:01:48 -0000	1.2
+++ tests/warnings/term_indirect_warning.exp	5 Sep 2006 12:22:44 -0000
@@ -1,4 +1,4 @@
 term_indirect_warning.m:011: Termination of predicate
-term_indirect_warning.m:011:   `term_indirect_warning.foo/3' mode 0 not proven
+term_indirect_warning.m:011:   `term_indirect_warning.foo'/3 mode 0 not proven
 term_indirect_warning.m:011:   for the following reason:
 term_indirect_warning.m:016: It contains a higher order call.
Index: tests/warnings/warn_dead_procs.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/warn_dead_procs.exp,v
retrieving revision 1.2
diff -u -b -r1.2 warn_dead_procs.exp
--- tests/warnings/warn_dead_procs.exp	14 May 2004 08:40:33 -0000	1.2
+++ tests/warnings/warn_dead_procs.exp	5 Sep 2006 12:22:44 -0000
@@ -1,4 +1,4 @@
 warn_dead_procs.m:016: Inferred :- pred baz.
-warn_dead_procs.m:008: Warning: predicate `foo/0' mode 0 is never called.
-warn_dead_procs.m:012: Warning: predicate `bar/1' mode 0 is never called.
-warn_dead_procs.m:013: Warning: predicate `bar/1' mode 1 is never called.
+warn_dead_procs.m:008: Warning: predicate `foo'/0 mode 0 is never called.
+warn_dead_procs.m:012: Warning: predicate `bar'/1 mode 0 is never called.
+warn_dead_procs.m:013: Warning: predicate `bar'/1 mode 1 is never called.
Index: tests/warnings/warn_stubs.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/warnings/warn_stubs.exp,v
retrieving revision 1.2
diff -u -b -r1.2 warn_stubs.exp
--- tests/warnings/warn_stubs.exp	14 May 2004 08:40:33 -0000	1.2
+++ tests/warnings/warn_stubs.exp	5 Sep 2006 12:23:12 -0000
@@ -1,3 +1,3 @@
-warn_stubs.m:004: Warning: no clauses for predicate `main/2'.
-warn_stubs.m:005: Warning: no clauses for predicate `foo/0'.
-warn_stubs.m:008: Warning: no clauses for predicate `main2/2'.
+warn_stubs.m:004: Warning: no clauses for predicate `main'/2.
+warn_stubs.m:005: Warning: no clauses for predicate `foo'/0.
+warn_stubs.m:008: Warning: no clauses for predicate `main2'/2.
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list