[m-rev.] diff: move the rest of mode_errors.m to use error_util

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Aug 22 13:54:53 AEST 2005


Move the rest of mode_errors.m to use error_util.

compiler/mode_errors.m:
	The parts of this module that generate error messages (as opposed to
	progress messages) now all return a description of the error to a
	central place for printing by error_util.m. This should make it
	significantly easier to add new error messages.

compiler/error_util.m:
	Add the new capability to support mode_errors.m: that of describing
	in one data structure a sequence of calls to write_error_pieces.

compiler/hlds_out.m:
	Given a bunch of existing predicates that print various things,
	provide versions that convert those things to strings, for use
	in mode_errors.m.

	Write_unify_context had two versions for printing and only one version
	for conversion to pieces; add the second version for conversion to
	pieces. Change the order of arguments of the five-argument version
	of write_unify_context to allow the use of state variables.

compiler/mercury_to_mercury.m:
compiler/prog_out.m:
	Given a bunch of existing predicates that print various things,
	provide versions that convert those things to strings, for use
	in hlds_out.m and mode_errors.m.

compiler/det_report.m:
	Conform to the changed argument order of write_unify_context.

library/term_io.m:
	Fix an old bug: the code of add_escaped_char wasn't actually doing
	any escaping. hlds_out.m now relies on it doing so.

tests/hard_coded/xmlable_test.m:
	Due to the bugfix in term_io.m, string__string now protects &s with
	backslashes; expect this.

tests/invalid/*.err_exp:
	Expect mode error messages in the new, better format.

Zoltan.

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/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.102
diff -u -b -r1.102 det_report.m
--- compiler/det_report.m	14 Aug 2005 05:45:56 -0000	1.102
+++ compiler/det_report.m	20 Aug 2005 10:37:28 -0000
@@ -910,9 +910,9 @@
     unify_context::in, det_info::in, prog_var::in, unify_rhs::in,
     io::di, io::uo) is det.
 
-det_report_unify_context(First0, Last, Context, UnifyContext, DetInfo,
+det_report_unify_context(!.First, Last, Context, UnifyContext, DetInfo,
         LHS, RHS, !IO) :-
-    hlds_out__write_unify_context(First0, UnifyContext, Context, First, !IO),
+    hlds_out__write_unify_context(!First, UnifyContext, Context, !IO),
     prog_out__write_context(Context, !IO),
     det_get_proc_info(DetInfo, ProcInfo),
     proc_info_varset(ProcInfo, VarSet),
@@ -921,7 +921,7 @@
         % proc_info, so we'll just make one up....
     varset__init(InstVarSet),
     (
-        First = yes,
+        !.First = yes,
         (
             Last = yes,
             io__write_string("  Unification ", !IO)
@@ -930,7 +930,7 @@
             io__write_string("  In unification ", !IO)
         )
     ;
-        First = no,
+        !.First = no,
         (
             Last = yes,
             io__write_string("  unification ", !IO)
@@ -1251,7 +1251,7 @@
         Pieces0 = [words("In switch on variable `" ++ VarStr ++ "':"), nl]
     ;
         GoalContext = unify(UnifyContext),
-        hlds_out__unify_context_to_pieces(UnifyContext, [], Pieces0)
+        hlds_out__unify_context_to_pieces(yes, _, UnifyContext, [], Pieces0)
     ),
     ( type_to_ctor_and_args(Type, TypeCtor, _TypeArgs) ->
         TypeCtorStr = hlds_out__type_ctor_to_string(TypeCtor)
Index: compiler/error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/error_util.m,v
retrieving revision 1.41
diff -u -b -r1.41 error_util.m
--- compiler/error_util.m	18 Aug 2005 07:57:51 -0000	1.41
+++ compiler/error_util.m	20 Aug 2005 12:08:32 -0000
@@ -92,6 +92,10 @@
 
 :- type format_components == list(format_component).
 
+    % Wrap words() around a string.
+    %
+:- func string_to_words_piece(string) = format_component.
+
     % Convert a list of strings into a list of format_components
     % separated by commas, with the last two elements separated by `and'.
     %
@@ -110,6 +114,14 @@
 :- func component_list_to_pieces(list(format_component)) =
     list(format_component).
 
+    % Convert a list of lines (each given by a list of format_components
+    % *without* a final nl) into a condensed list of format_components
+    % in which adjacent lines are separated by commas and newlines,
+    % with only a newline (no comma) after the last.
+    %
+:- func component_list_to_line_pieces(list(list(format_component))) =
+    list(format_component).
+
     % choose_number(List, Singular, Plural) = Form
     %
     % Choose between a singular version and a plural version of something,
@@ -156,6 +168,44 @@
 
 :- 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.
+    %
+    % 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 error_msg_spec
+    --->    error_msg_spec(
+                spec_treat_as_first     :: bool,
+                spec_context            :: prog_context,
+                spec_extra_indent       :: int,
+                spec_pieces             :: list(format_component)
+            )
+    ;       anything(
+                spec_write_anything     :: pred(io, io)
+            ).
+
+:- inst error_msg_spec ==
+        bound(
+            error_msg_spec(ground, ground, ground, ground)
+        ;
+            anything(pred(di, uo) is det)
+        ).
+:- inst error_msg_specs == list_skel(error_msg_spec).
+
+:- pred write_error_specs(list(error_msg_spec)::in(error_msg_specs),
+    io::di, io::uo) is det.
+
 :- func describe_sym_name(sym_name) = string.
 
 :- func describe_sym_name_and_arity(sym_name_and_arity) = string.
@@ -236,6 +286,39 @@
 :- import_module string.
 :- import_module term.
 
+write_error_specs(Specs, !IO) :-
+    write_error_specs_2(Specs, yes, !IO).
+
+:- pred write_error_specs_2(list(error_msg_spec)::in(error_msg_specs),
+    bool::in, io::di, io::uo) is det.
+
+write_error_specs_2([], _First, !IO).
+write_error_specs_2([Spec | Specs], !.First, !IO) :-
+    (
+        Spec = error_msg_spec(TreatAsFirst, Context, ExtraIndent, Pieces),
+        (
+            TreatAsFirst = yes,
+            !:First = yes
+        ;
+            TreatAsFirst = no
+        ),
+        Indent = ExtraIndent * indent_increment,
+        (
+            !.First = yes,
+            write_error_pieces(Context, Indent, Pieces, !IO)
+        ;
+            !.First = no,
+            write_error_pieces_not_first_line(Context, Indent, Pieces, !IO)
+        ),
+        !:First = no
+    ;
+        Spec = anything(Pred),
+        Pred(!IO)
+    ),
+    write_error_specs_2(Specs, !.First, !IO).
+
+string_to_words_piece(Str) = words(Str).
+
 list_to_pieces([]) = [].
 list_to_pieces([Elem]) = [words(Elem)].
 list_to_pieces([Elem1, Elem2]) = [fixed(Elem1), words("and"), fixed(Elem2)].
@@ -259,6 +342,12 @@
         [Component1, Component2, Component3 | Components]) =
     list__append(append_punctuation([Component1], ','),
         component_list_to_pieces([Component2, Component3 | Components])).
+
+component_list_to_line_pieces([]) = [].
+component_list_to_line_pieces([Components]) = Components ++ [nl].
+component_list_to_line_pieces([Components1, Components2 | ComponentLists]) =
+    list__append(Components1 ++ [suffix(","), nl],
+        component_list_to_line_pieces([Components2 | ComponentLists])).
 
 choose_number([], _Singular, Plural) = Plural.
 choose_number([_], Singular, _Plural) = Singular.
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.364
diff -u -b -r1.364 hlds_out.m
--- compiler/hlds_out.m	16 Aug 2005 15:36:16 -0000	1.364
+++ compiler/hlds_out.m	21 Aug 2005 01:45:52 -0000
@@ -73,12 +73,16 @@
     %
 :- pred hlds_out__write_pred_id(module_info::in, pred_id::in, io::di, io::uo)
     is det.
+:- func hlds_out__pred_id_to_string(module_info, pred_id) = string.
 
 :- pred hlds_out__write_pred_proc_id(module_info::in, pred_proc_id::in, io::di,
     io::uo) is det.
+:- func hlds_out__pred_proc_id_to_string(module_info, pred_proc_id) = string.
 
 :- pred hlds_out__write_pred_proc_id(module_info::in, pred_id::in, proc_id::in,
     io::di, io::uo) is det.
+:- func hlds_out__pred_proc_id_to_string(module_info, pred_id, proc_id)
+    = string.
 
 :- pred hlds_out__write_call_id(call_id::in, io::di, io::uo) is det.
 :- func hlds_out__call_id_to_string(call_id) = string.
@@ -99,6 +103,8 @@
     %
 :- pred hlds_out__write_unify_context(unify_context::in, prog_context::in,
     io::di, io::uo) is det.
+:- pred hlds_out__unify_context_to_pieces(unify_context::in,
+    list(format_component)::in, list(format_component)::out) is det.
 
     % hlds_out__write_unify_context_first/6 is the same as above, except that
     % it also takes and returns a bool which specifies whether this is the
@@ -107,13 +113,13 @@
     % a capital letter, e.g.
     %   foo.m:123:   In argument 3 of functor `foo/5':
     %   foo.m:123:   in unification of `X' and `blah':
-    % The bool returned as the fourth argument will be `no' unless nothing
+    % 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 hlds_out__write_unify_context(bool::in, unify_context::in,
-    prog_context::in, bool::out, io::di, io::uo) is det.
-
-:- pred hlds_out__unify_context_to_pieces(unify_context::in,
+:- pred hlds_out__write_unify_context(bool::in, bool::out, unify_context::in,
+    prog_context::in, io::di, io::uo) is det.
+:- pred hlds_out__unify_context_to_pieces(bool::in, bool::out,
+    unify_context::in,
     list(format_component)::in, list(format_component)::out) is det.
 
 :- pred hlds_out__write_determinism(determinism::in, io::di, io::uo) is det.
@@ -183,6 +189,8 @@
     %
 :- pred hlds_out__write_functor(const::in, list(prog_var)::in, prog_varset::in,
     bool::in, io::di, io::uo) is det.
+:- func hlds_out__functor_to_string(const, list(prog_var), prog_varset, bool)
+    = string.
 
     % Print out a cons_id and arguments. The module_info and prog_varset
     % give the context. The boolean says whether variables should have
@@ -190,6 +198,8 @@
     %
 :- pred hlds_out__write_functor_cons_id(cons_id::in, list(prog_var)::in,
     prog_varset::in, module_info::in, bool::in, io::di, io::uo) is det.
+:- func hlds_out__functor_cons_id_to_string(cons_id, list(prog_var),
+    prog_varset, module_info, bool) = string.
 
     % Print out the right-hand-side of a unification. The module_info and
     % the varsets give the context of the rhs. The boolean says whether
@@ -207,6 +217,8 @@
     %
 :- pred hlds_out__write_var_modes(list(prog_var)::in, list(mode)::in,
     prog_varset::in, inst_varset::in, bool::in, io::di, io::uo) is det.
+:- func hlds_out__var_modes_to_string(list(prog_var), list(mode),
+    prog_varset, inst_varset, bool) = string.
 
 :- pred hlds_out__write_instmap(instmap::in, prog_varset::in, bool::in,
     int::in, io::di, io::uo) is det.
@@ -354,6 +366,9 @@
     % hlds_error_util__describe_one_pred_name. Changes here should be made
     % there as well.
 hlds_out__write_pred_id(ModuleInfo, PredId, !IO) :-
+    io__write_string(hlds_out__pred_id_to_string(ModuleInfo, PredId), !IO).
+
+hlds_out__pred_id_to_string(ModuleInfo, PredId) = Str :-
     module_info_preds(ModuleInfo, PredTable),
     ( map__search(PredTable, PredId, PredInfo) ->
         Module = pred_info_module(PredInfo),
@@ -365,43 +380,47 @@
             Origin = special_pred(SpecialId - TypeCtor)
         ->
             special_pred_description(SpecialId, Descr),
-            io__write_string(Descr, !IO),
             TypeCtor = _TypeSymName - TypeArity,
             ( TypeArity = 0 ->
-                io__write_string(" for type ", !IO)
+                ForStr = " for type "
             ;
-                io__write_string(" for type constructor ", !IO)
+                ForStr = " for type constructor "
             ),
-            hlds_out__write_type_name(TypeCtor, !IO)
+            Str = Descr ++ ForStr ++ hlds_out__type_name_to_string(TypeCtor)
         ;
             pred_info_get_markers(PredInfo, Markers),
             check_marker(Markers, class_instance_method)
         ->
-            io__write_string("type class method implementation", !IO)
+            Str = "type class method implementation"
         ;
             pred_info_get_goal_type(PredInfo, promise(PromiseType))
         ->
-            io__write_string("`" ++ prog_out__promise_to_string(PromiseType)
-                ++ "' declaration", !IO)
+            Str = "`" ++ prog_out__promise_to_string(PromiseType)
+                ++ "' declaration"
         ;
-            write_simple_call_id(PredOrFunc, qualified(Module, Name), Arity,
-                !IO)
+            Str = simple_call_id_to_string(PredOrFunc, qualified(Module, Name),
+                Arity)
         )
     ;
         % The predicate has been deleted, so we print what we can.
         pred_id_to_int(PredId, PredIdInt),
-        io__write_string("deleted predicate ", !IO),
-        io__write_int(PredIdInt, !IO)
+        Str = "deleted predicate " ++ int_to_string(PredIdInt)
     ).
 
 hlds_out__write_pred_proc_id(ModuleInfo, proc(PredId, ProcId), !IO) :-
     hlds_out__write_pred_proc_id(ModuleInfo, PredId, ProcId, !IO).
 
+hlds_out__pred_proc_id_to_string(ModuleInfo, proc(PredId, ProcId)) =
+    hlds_out__pred_proc_id_to_string(ModuleInfo, PredId, ProcId).
+
 hlds_out__write_pred_proc_id(ModuleInfo, PredId, ProcId, !IO) :-
-    hlds_out__write_pred_id(ModuleInfo, PredId, !IO),
-    io__write_string(" mode ", !IO),
+    io__write_string(
+        hlds_out__pred_proc_id_to_string(ModuleInfo, PredId, ProcId), !IO).
+
+hlds_out__pred_proc_id_to_string(ModuleInfo, PredId, ProcId) = Str :-
     proc_id_to_int(ProcId, ModeNum),
-    io__write_int(ModeNum, !IO).
+    Str = hlds_out__pred_id_to_string(ModuleInfo, PredId)
+        ++ " mode " ++ int_to_string(ModeNum).
 
 hlds_out__write_call_id(CallId, !IO) :-
     Str = hlds_out__call_id_to_string(CallId),
@@ -563,37 +582,39 @@
 %-----------------------------------------------------------------------------%
 
 hlds_out__write_unify_context(UnifyContext, Context, !IO) :-
-    hlds_out__write_unify_context(no, UnifyContext, Context, _, !IO).
+    hlds_out__write_unify_context(no, _, UnifyContext, Context, !IO).
+
+hlds_out__unify_context_to_pieces(UnifyContext, !Pieces) :-
+    hlds_out__unify_context_to_pieces(no, _, UnifyContext, !Pieces).
 
-hlds_out__write_unify_context(First0, UnifyContext, Context, First, !IO) :-
+hlds_out__write_unify_context(!First, UnifyContext, Context, !IO) :-
     UnifyContext = unify_context(MainContext, RevSubContexts),
     list__reverse(RevSubContexts, SubContexts),
-    hlds_out__write_unify_main_context(First0, MainContext, Context, First1,
-        !IO),
-    hlds_out__write_unify_sub_contexts(First1, SubContexts, Context, First,
-        !IO).
+    hlds_out__write_unify_main_context(!First, MainContext, Context, !IO),
+    hlds_out__write_unify_sub_contexts(!First, SubContexts, Context, !IO).
 
-hlds_out__unify_context_to_pieces(UnifyContext, !Pieces) :-
+hlds_out__unify_context_to_pieces(!First, UnifyContext, !Pieces) :-
     UnifyContext = unify_context(MainContext, RevSubContexts),
     list__reverse(RevSubContexts, SubContexts),
-    hlds_out__unify_main_context_to_pieces(MainContext, !Pieces),
-    hlds_out__unify_sub_contexts_to_pieces(SubContexts, !Pieces).
+    hlds_out__unify_main_context_to_pieces(!First, MainContext, !Pieces),
+    hlds_out__unify_sub_contexts_to_pieces(!First, SubContexts, !Pieces).
 
-:- pred hlds_out__write_unify_main_context(bool::in, unify_main_context::in,
-    prog_context::in, bool::out, io::di, io::uo) is det.
+:- pred hlds_out__write_unify_main_context(bool::in, bool::out,
+    unify_main_context::in, prog_context::in, io::di, io::uo) is det.
 
-hlds_out__write_unify_main_context(First, explicit, _, First, !IO).
-hlds_out__write_unify_main_context(First, head(ArgNum), Context, no, !IO) :-
-    hlds_out__write_in_argument(First, ArgNum, Context, !IO),
+hlds_out__write_unify_main_context(!First, explicit, _, !IO).
+hlds_out__write_unify_main_context(!First, head(ArgNum), Context, !IO) :-
+    hlds_out__write_in_argument(!.First, ArgNum, Context, !IO),
+    !:First = no,
     io__write_string(" of clause head:\n", !IO).
-
-hlds_out__write_unify_main_context(First, head_result, Context, no, !IO) :-
-    hlds_out__start_in_message(First, Context, !IO),
+hlds_out__write_unify_main_context(!First, head_result, Context, !IO) :-
+    hlds_out__start_in_message(!.First, Context, !IO),
+    !:First = no,
     io__write_string("function result term of clause head:\n", !IO).
-
-hlds_out__write_unify_main_context(First, call(CallId, ArgNum), Context, no,
+hlds_out__write_unify_main_context(!First, call(CallId, ArgNum), Context,
         !IO) :-
-    hlds_out__start_in_message(First, Context, !IO),
+    hlds_out__start_in_message(!.First, Context, !IO),
+    !:First = no,
     % The markers argument below is used only for type class method
     % implementations defined using the named syntax rather than
     % the clause syntax, and the bodies of such procedures should
@@ -604,24 +625,27 @@
     init_markers(Markers),
     hlds_out__write_call_arg_id(CallId, ArgNum, Markers, !IO),
     io__write_string(":\n", !IO).
-
-hlds_out__write_unify_main_context(First, implicit(Source), Context, First,
-        !IO) :-
-    hlds_out__start_in_message(First, Context, !IO),
+hlds_out__write_unify_main_context(!First, implicit(Source), Context, !IO) :-
+    hlds_out__start_in_message(!.First, Context, !IO),
     io__format("implicit %s unification:\n", [s(Source)], !IO).
 
-:- pred hlds_out__unify_main_context_to_pieces(unify_main_context::in,
+:- pred hlds_out__unify_main_context_to_pieces(bool::in, bool::out,
+    unify_main_context::in,
     list(format_component)::in, list(format_component)::out) is det.
 
-hlds_out__unify_main_context_to_pieces(explicit, !Pieces).
-hlds_out__unify_main_context_to_pieces(head(ArgNum), !Pieces) :-
-    hlds_out__in_argument_to_pieces(ArgNum, !Pieces),
+hlds_out__unify_main_context_to_pieces(!First, explicit, !Pieces).
+hlds_out__unify_main_context_to_pieces(!First, head(ArgNum), !Pieces) :-
+    hlds_out__in_argument_to_pieces(!.First, ArgNum, !Pieces),
+    !:First = no,
     !:Pieces = !.Pieces ++ [words("of clause head:"), nl].
-hlds_out__unify_main_context_to_pieces(head_result, !Pieces) :-
-    hlds_out__start_in_message_to_pieces(!Pieces),
+hlds_out__unify_main_context_to_pieces(!First, head_result, !Pieces) :-
+    hlds_out__start_in_message_to_pieces(!.First, !Pieces),
+    !:First = no,
     !:Pieces = !.Pieces ++ [words("function result term of clause head:"), nl].
-hlds_out__unify_main_context_to_pieces(call(CallId, ArgNum), !Pieces) :-
-    hlds_out__start_in_message_to_pieces(!Pieces),
+hlds_out__unify_main_context_to_pieces(!First, call(CallId, ArgNum),
+        !Pieces) :-
+    hlds_out__start_in_message_to_pieces(!.First, !Pieces),
+    !:First = no,
     % The markers argument below is used only for type class method
     % implementations defined using the named syntax rather than
     % the clause syntax, and the bodies of such procedures should
@@ -632,34 +656,37 @@
     init_markers(Markers),
     ArgIdStr = hlds_out__call_arg_id_to_string(CallId, ArgNum, Markers),
     !:Pieces = !.Pieces ++ [words(ArgIdStr ++ ":"), nl].
-hlds_out__unify_main_context_to_pieces(implicit(Source), !Pieces) :-
-    hlds_out__start_in_message_to_pieces(!Pieces),
+hlds_out__unify_main_context_to_pieces(!First, implicit(Source), !Pieces) :-
+    hlds_out__start_in_message_to_pieces(!.First, !Pieces),
     string__format("implicit %s unification:\n", [s(Source)], Msg),
-    !:Pieces = !.Pieces ++ [words(Msg)].
+    !:Pieces = !.Pieces ++ [words(Msg), nl].
 
-:- pred hlds_out__write_unify_sub_contexts(bool::in, unify_sub_contexts::in,
-    prog_context::in, bool::out, io::di, io::uo) is det.
+:- pred hlds_out__write_unify_sub_contexts(bool::in, bool::out,
+    unify_sub_contexts::in, prog_context::in, io::di, io::uo) is det.
 
-hlds_out__write_unify_sub_contexts(First, [], _, First, !IO).
-hlds_out__write_unify_sub_contexts(First0, [ConsId - ArgNum | SubContexts],
-        Context, First, !IO) :-
-    hlds_out__write_in_argument(First0, ArgNum, Context, !IO),
+hlds_out__write_unify_sub_contexts(!First, [], _, !IO).
+hlds_out__write_unify_sub_contexts(!First, [ConsId - ArgNum | SubContexts],
+        Context, !IO) :-
+    hlds_out__write_in_argument(!.First, ArgNum, Context, !IO),
+    !:First = no,
     io__write_string(" of functor `", !IO),
     hlds_out__write_cons_id(ConsId, !IO),
     io__write_string("':\n", !IO),
-    hlds_out__write_unify_sub_contexts(no, SubContexts, Context, First, !IO).
+    hlds_out__write_unify_sub_contexts(!First, SubContexts, Context, !IO).
 
-:- pred hlds_out__unify_sub_contexts_to_pieces(unify_sub_contexts::in,
+:- pred hlds_out__unify_sub_contexts_to_pieces(bool::in, bool::out,
+    unify_sub_contexts::in,
     list(format_component)::in, list(format_component)::out) is det.
 
-hlds_out__unify_sub_contexts_to_pieces([], !Pieces).
-hlds_out__unify_sub_contexts_to_pieces([ConsId - ArgNum | SubContexts],
+hlds_out__unify_sub_contexts_to_pieces(!First, [], !Pieces).
+hlds_out__unify_sub_contexts_to_pieces(!First, [ConsId - ArgNum | SubContexts],
         !Pieces) :-
-    hlds_out__in_argument_to_pieces(ArgNum, !Pieces),
+    hlds_out__in_argument_to_pieces(!.First, ArgNum, !Pieces),
+    !:First = no,
     NewPieces = [words("of functor"),
         fixed("`" ++ cons_id_to_string(ConsId) ++ "':"), nl],
     !:Pieces = !.Pieces ++ NewPieces,
-    hlds_out__unify_sub_contexts_to_pieces(SubContexts, !Pieces).
+    hlds_out__unify_sub_contexts_to_pieces(!First, SubContexts, !Pieces).
 
 :- pred hlds_out__write_in_argument(bool::in, int::in, prog_context::in,
     io::di, io::uo) is det.
@@ -669,11 +696,11 @@
     io__write_string("argument ", !IO),
     io__write_int(ArgNum, !IO).
 
-:- pred hlds_out__in_argument_to_pieces(int::in,
+:- pred hlds_out__in_argument_to_pieces(bool::in, int::in,
     list(format_component)::in, list(format_component)::out) is det.
 
-hlds_out__in_argument_to_pieces(ArgNum, !Pieces) :-
-    hlds_out__start_in_message_to_pieces(!Pieces),
+hlds_out__in_argument_to_pieces(First, ArgNum, !Pieces) :-
+    hlds_out__start_in_message_to_pieces(First, !Pieces),
     ArgNumStr = int_to_string(ArgNum),
     !:Pieces = !.Pieces ++ [words("argument"), words(ArgNumStr)].
 
@@ -682,21 +709,25 @@
 
 hlds_out__start_in_message(First, Context, !IO) :-
     prog_out__write_context(Context, !IO),
-    ( First = yes ->
+    (
+        First = yes,
         io__write_string("  In ", !IO)
     ;
+        First = no,
         io__write_string("  in ", !IO)
     ).
 
-:- pred hlds_out__start_in_message_to_pieces(
+:- pred hlds_out__start_in_message_to_pieces(bool::in,
     list(format_component)::in, list(format_component)::out) is det.
 
-hlds_out__start_in_message_to_pieces(!Pieces) :-
+hlds_out__start_in_message_to_pieces(First, !Pieces) :-
     (
-        !.Pieces = [],
+        First = yes,
+        % It is possible for First to be yes and !.Pieces to be nonempty,
+        % since !.Pieces may contain stuff from before the unify context.
         !:Pieces = !.Pieces ++ [words("In")]
     ;
-        !.Pieces = [_ | _],
+        First = no,
         !:Pieces = !.Pieces ++ [words("in")]
     ).
 
@@ -1863,8 +1894,8 @@
         )
     ->
         (
-            % don't output bogus info if we haven't been through
-            % mode analysis yet
+            % Don't output bogus info if we haven't been through
+            % mode analysis yet.
             Unification = complicated_unify(Mode, CanFail, TypeInfoVars),
             CanFail = can_fail,
             Mode = (free - free -> free - free),
@@ -2521,8 +2552,8 @@
             io__write_string(")", !IO)
         ),
         io__write_string(" = (", !IO),
-        hlds_out__write_var_mode(RetVar, RetMode, VarSet, InstVarSet,
-            AppendVarNums, !IO),
+        hlds_out__write_var_mode(VarSet, InstVarSet, AppendVarNums,
+            RetVar - RetMode, !IO),
         io__write_string(") is ", !IO),
         mercury_output_det(Det, !IO),
         io__write_string(" :-\n", !IO),
@@ -2543,12 +2574,13 @@
     ),
     globals__io_lookup_string_option(dump_hlds_options, Verbose, !IO),
     ( string__contains_char(Verbose, 'n') ->
-        ( NonLocals \= [] ->
+        (
+            NonLocals = [_ | _],
             hlds_out__write_indent(Indent1, !IO),
             io__write_string("% lambda nonlocals: ", !IO),
             mercury_output_vars(NonLocals, VarSet, AppendVarNums, !IO)
         ;
-            true
+            NonLocals = []
         )
     ;
         true
@@ -2573,25 +2605,46 @@
     hlds_out__write_functor(Functor, ArgVars, VarSet, AppendVarNums,
         not_next_to_graphic_token, !IO).
 
+hlds_out__functor_to_string(Functor, ArgVars, VarSet, AppendVarNums) =
+    hlds_out__functor_to_string(Functor, ArgVars, VarSet, AppendVarNums,
+        not_next_to_graphic_token).
+
 :- pred hlds_out__write_functor(const::in, list(prog_var)::in, prog_varset::in,
     bool::in, needs_quotes::in, io::di, io::uo) is det.
 
 hlds_out__write_functor(Functor, ArgVars, VarSet, AppendVarNums,
         NextToGraphicToken, !IO) :-
+    io__write_string(hlds_out__functor_to_string(Functor, ArgVars, VarSet,
+        AppendVarNums, NextToGraphicToken), !IO).
+
+:- func hlds_out__functor_to_string(const, list(prog_var), prog_varset,
+    bool, needs_quotes) = string.
+
+hlds_out__functor_to_string(Functor, ArgVars, VarSet, AppendVarNums,
+        NextToGraphicToken) = Str :-
     term__context_init(Context),
     term__var_list_to_term_list(ArgVars, ArgTerms),
     Term = term__functor(Functor, ArgTerms, Context),
-    mercury_output_term(Term, VarSet, AppendVarNums, NextToGraphicToken, !IO).
+    Str = mercury_term_to_string(Term, VarSet, AppendVarNums,
+        NextToGraphicToken).
 
 :- pred hlds_out__write_qualified_functor(module_name::in, const::in,
     list(prog_var)::in, prog_varset::in, bool::in, io::di, io::uo) is det.
 
 hlds_out__write_qualified_functor(ModuleName, Functor, ArgVars, VarSet,
         AppendVarNums, !IO) :-
-    mercury_output_bracketed_sym_name(ModuleName, !IO),
-    io__write_string(".", !IO),
-    hlds_out__write_functor(Functor, ArgVars, VarSet, AppendVarNums,
-        next_to_graphic_token, !IO).
+    io__write_string(hlds_out__qualified_functor_to_string(ModuleName, Functor,
+        ArgVars, VarSet, AppendVarNums), !IO).
+
+:- func hlds_out__qualified_functor_to_string(module_name, const,
+    list(prog_var), prog_varset, bool) = string.
+
+hlds_out__qualified_functor_to_string(ModuleName, Functor, ArgVars, VarSet,
+        AppendVarNums) = Str :-
+    ModuleNameStr = mercury_bracketed_sym_name_to_string(ModuleName),
+    FunctorStr = hlds_out__functor_to_string(Functor, ArgVars, VarSet,
+        AppendVarNums, next_to_graphic_token),
+    Str = ModuleNameStr ++ "." ++ FunctorStr.
 
 :- pred hlds_out__write_qualified_functor_with_term_args(module_name::in,
     const::in, list(prog_term)::in, prog_varset::in, bool::in,
@@ -2599,130 +2652,131 @@
 
 hlds_out__write_qualified_functor_with_term_args(ModuleName, Functor,
         ArgTerms, VarSet, AppendVarNums, !IO) :-
-    mercury_output_bracketed_sym_name(ModuleName, !IO),
-    io__write_string(".", !IO),
+    io__write_string(
+        hlds_out__qualified_functor_with_term_args_to_string(ModuleName,
+        Functor, ArgTerms, VarSet, AppendVarNums), !IO).
+
+:- func hlds_out__qualified_functor_with_term_args_to_string(module_name,
+    const, list(prog_term), prog_varset, bool) = string.
+
+hlds_out__qualified_functor_with_term_args_to_string(ModuleName, Functor,
+        ArgTerms, VarSet, AppendVarNums) = Str :-
+    ModuleNameStr = mercury_bracketed_sym_name_to_string(ModuleName),
     term__context_init(Context),
-    mercury_output_term(term__functor(Functor, ArgTerms, Context), VarSet,
-        AppendVarNums, next_to_graphic_token, !IO).
+    TermStr = mercury_term_to_string(term__functor(Functor, ArgTerms, Context),
+        VarSet, AppendVarNums, next_to_graphic_token),
+    Str = ModuleNameStr ++ "." ++ TermStr.
 
 hlds_out__write_functor_cons_id(ConsId, ArgVars, VarSet, ModuleInfo,
         AppendVarNums, !IO) :-
+    io__write_string(hlds_out__functor_cons_id_to_string(ConsId, ArgVars,
+        VarSet, ModuleInfo, AppendVarNums), !IO).
+
+hlds_out__functor_cons_id_to_string(ConsId, ArgVars, VarSet, ModuleInfo,
+        AppendVarNums) = Str :-
     (
         ConsId = cons(SymName, _),
         (
             SymName = qualified(Module, Name),
-            hlds_out__write_qualified_functor(Module, term__atom(Name),
-                ArgVars, VarSet, AppendVarNums, !IO)
+            Str = hlds_out__qualified_functor_to_string(Module,
+                term__atom(Name), ArgVars, VarSet, AppendVarNums)
         ;
             SymName = unqualified(Name),
-            hlds_out__write_functor(term__atom(Name),
-                ArgVars, VarSet, AppendVarNums, next_to_graphic_token, !IO)
+            Str = hlds_out__functor_to_string(term__atom(Name),
+                ArgVars, VarSet, AppendVarNums, next_to_graphic_token)
         )
     ;
         ConsId = int_const(Int),
-        hlds_out__write_functor(term__integer(Int), ArgVars, VarSet,
-            AppendVarNums, !IO)
+        Str = hlds_out__functor_to_string(term__integer(Int), ArgVars,
+            VarSet, AppendVarNums)
     ;
         ConsId = float_const(Float),
-        hlds_out__write_functor(term__float(Float), ArgVars, VarSet,
-            AppendVarNums, !IO)
+        Str = hlds_out__functor_to_string(term__float(Float), ArgVars,
+            VarSet, AppendVarNums)
     ;
-        ConsId = string_const(Str),
-        hlds_out__write_functor(term__string(Str), ArgVars, VarSet,
-            AppendVarNums, !IO)
+        ConsId = string_const(String),
+        Str = hlds_out__functor_to_string(term__string(String), ArgVars,
+            VarSet, AppendVarNums)
     ;
         ConsId = pred_const(ShroudedPredProcId, _),
         proc(PredId, _) = unshroud_pred_proc_id(ShroudedPredProcId),
         module_info_pred_info(ModuleInfo, PredId, PredInfo),
         PredModule = pred_info_module(PredInfo),
         PredName = pred_info_name(PredInfo),
-        hlds_out__write_functor_cons_id(
+        Str = hlds_out__functor_cons_id_to_string(
             cons(qualified(PredModule, PredName), list__length(ArgVars)),
-            ArgVars, VarSet, ModuleInfo, AppendVarNums, !IO)
+            ArgVars, VarSet, ModuleInfo, AppendVarNums)
     ;
         ConsId = type_ctor_info_const(Module, Name, Arity),
-        io__write_string("type_ctor_info(""", !IO),
-        prog_out__write_sym_name(Module, !IO),
-        io__write_string(""", """, !IO),
-        io__write_string(Name, !IO),
-        io__write_string(""", ", !IO),
-        io__write_int(Arity, !IO),
-        io__write_string(")", !IO)
-    ;
-        ConsId = base_typeclass_info_const(Module,
-            class_id(Name, Arity), _, Instance),
-        io__write_string("base_typeclass_info(""", !IO),
-        prog_out__write_sym_name(Module, !IO),
-        io__write_string(""", ", !IO),
-        io__write_string("class_id(", !IO),
-        prog_out__write_sym_name(Name, !IO),
-        io__write_string(", ", !IO),
-        io__write_int(Arity, !IO),
-        io__write_string("), ", !IO),
-        io__write_string(Instance, !IO),
-        io__write_string(")", !IO)
+        Str = "type_ctor_info("""
+            ++ prog_out__sym_name_to_escaped_string(Module)
+            ++ """, """ ++ Name ++ """, " ++ int_to_string(Arity) ++ ")"
+    ;
+        ConsId = base_typeclass_info_const(Module, class_id(Name, Arity), _,
+            Instance),
+        Str = "base_typeclass_info("""
+            ++ prog_out__sym_name_to_escaped_string(Module) ++ """, "
+            ++ "class_id(" ++ prog_out__sym_name_to_escaped_string(Name)
+            ++ ", " ++ int_to_string(Arity) ++ "), " ++ Instance ++ ")"
     ;
         ConsId = type_info_cell_constructor(_),
-        hlds_out__write_functor(term__atom("type_info_cell_constructor"),
-            ArgVars, VarSet, AppendVarNums, next_to_graphic_token, !IO)
+        Str = hlds_out__functor_to_string(
+            term__atom("type_info_cell_constructor"),
+            ArgVars, VarSet, AppendVarNums, next_to_graphic_token)
     ;
         ConsId = typeclass_info_cell_constructor,
-        hlds_out__write_functor(term__atom("typeclass_info_cell_constructor"),
-            ArgVars, VarSet, AppendVarNums, next_to_graphic_token, !IO)
+        Str = hlds_out__functor_to_string(
+            term__atom("typeclass_info_cell_constructor"),
+            ArgVars, VarSet, AppendVarNums, next_to_graphic_token)
     ;
         ConsId = tabling_pointer_const(ShroudedPredProcId),
         proc(PredId, ProcId) = unshroud_pred_proc_id(ShroudedPredProcId),
-        io__write_string("tabling_pointer_const(", !IO),
-        hlds_out__write_pred_id(ModuleInfo, PredId, !IO),
-        io__write_string(", ", !IO),
         proc_id_to_int(ProcId, ProcIdInt),
-        io__write_int(ProcIdInt, !IO),
-        io__write_string(")", !IO)
+        Str = "tabling_pointer_const("
+            ++ hlds_out__pred_id_to_string(ModuleInfo, PredId)
+            ++ ", " ++ int_to_string(ProcIdInt) ++ ")"
     ;
         ConsId = deep_profiling_proc_layout(ShroudedPredProcId),
         proc(PredId, ProcId) = unshroud_pred_proc_id(ShroudedPredProcId),
-        io__write_string("deep_profiling_proc_layout(", !IO),
-        hlds_out__write_pred_id(ModuleInfo, PredId, !IO),
         proc_id_to_int(ProcId, ProcIdInt),
-        io__write_string(" (mode ", !IO),
-        io__write_int(ProcIdInt, !IO),
-        io__write_string("))", !IO)
+        Str = "deep_profiling_proc_layout("
+            ++ hlds_out__pred_id_to_string(ModuleInfo, PredId)
+            ++ " (mode " ++ int_to_string(ProcIdInt) ++ "))"
     ;
         ConsId = table_io_decl(ShroudedPredProcId),
         proc(PredId, ProcId) = unshroud_pred_proc_id(ShroudedPredProcId),
-        io__write_string("table_io_decl(", !IO),
-        hlds_out__write_pred_id(ModuleInfo, PredId, !IO),
         proc_id_to_int(ProcId, ProcIdInt),
-        io__write_string(" (mode ", !IO),
-        io__write_int(ProcIdInt, !IO),
-        io__write_string("))", !IO)
+        Str = "table_io_decl("
+            ++ hlds_out__pred_id_to_string(ModuleInfo, PredId)
+            ++ " (mode " ++ int_to_string(ProcIdInt) ++ "))"
     ).
 
-hlds_out__write_var_modes([], [], _, _, _, !IO).
-hlds_out__write_var_modes([Var | Vars], [Mode | Modes], VarSet, InstVarSet,
-        AppendVarNums, !IO) :-
-    hlds_out__write_var_mode(Var, Mode, VarSet, InstVarSet, AppendVarNums,
-        !IO),
-    (
-        Vars = [_ | _],
-        io__write_string(", ", !IO)
-    ;
-        Vars = []
-    ),
-    hlds_out__write_var_modes(Vars, Modes, VarSet, InstVarSet,
-        AppendVarNums, !IO).
-hlds_out__write_var_modes([], [_ | _], _, _, _, !IO) :-
-    error("hlds_out__write_var_modes: length mis-match").
-hlds_out__write_var_modes([_ | _], [], _, _, _, !IO) :-
-    error("hlds_out__write_var_modes: length mis-match").
-
-:- pred hlds_out__write_var_mode(prog_var::in, (mode)::in, prog_varset::in,
-    inst_varset::in, bool::in, io::di, io::uo) is det.
+hlds_out__write_var_modes(Vars, Modes, VarSet, InstVarSet, AppendVarNums,
+        !IO) :-
+    io__write_string(hlds_out__var_modes_to_string(Vars, Modes, VarSet,
+        InstVarSet, AppendVarNums), !IO).
 
-hlds_out__write_var_mode(Var, Mode, VarSet, InstVarSet, AppendVarNums, !IO) :-
-    mercury_output_var(Var, VarSet, AppendVarNums, !IO),
-    io__write_string("::", !IO),
-    mercury_output_mode(Mode, InstVarSet, !IO).
+hlds_out__var_modes_to_string(Vars, Modes, VarSet, InstVarSet, AppendVarNums)
+        = Str :-
+    assoc_list__from_corresponding_lists(Vars, Modes, VarModes),
+    Strs = list__map(
+        hlds_out__var_mode_to_string(VarSet, InstVarSet, AppendVarNums),
+        VarModes),
+    Str = string__join_list(", ", Strs).
+
+:- pred hlds_out__write_var_mode(prog_varset::in, inst_varset::in, bool::in,
+    pair(prog_var, (mode))::in, io::di, io::uo) is det.
+
+hlds_out__write_var_mode(VarSet, InstVarSet, AppendVarNums, Var - Mode, !IO) :-
+    io__write_string(hlds_out__var_mode_to_string(VarSet, InstVarSet,
+        AppendVarNums, Var - Mode), !IO).
+
+:- func hlds_out__var_mode_to_string(prog_varset, inst_varset, bool,
+    pair(prog_var, (mode))) = string.
+
+hlds_out__var_mode_to_string(VarSet, InstVarSet, AppendVarNums, Var - Mode) =
+    mercury_var_to_string(Var, VarSet, AppendVarNums)
+    ++ "::" ++ mercury_mode_to_string(Mode, InstVarSet).
 
 :- pred hlds_out__write_conj(hlds_goal::in, list(hlds_goal)::in,
     module_info::in, prog_varset::in, bool::in, int::in, string::in,
@@ -3151,6 +3205,11 @@
 
 hlds_out__write_type_name(Name - _Arity, !IO) :-
     prog_out__write_sym_name(Name, !IO).
+
+:- func hlds_out__type_name_to_string(type_ctor) = string.
+
+hlds_out__type_name_to_string(Name - _Arity) =
+    prog_out__sym_name_to_escaped_string(Name).
 
 :- pred hlds_out__write_type_params(tvarset::in, list(type_param)::in,
     io::di, io::uo) is det.
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.261
diff -u -b -r1.261 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m	14 Aug 2005 03:20:39 -0000	1.261
+++ compiler/mercury_to_mercury.m	20 Aug 2005 03:59:31 -0000
@@ -273,9 +273,11 @@
 
 :- pred mercury_output_bracketed_sym_name(sym_name::in,
     io::di, io::uo) is det.
+:- func mercury_bracketed_sym_name_to_string(sym_name) = string.
 
 :- pred mercury_output_bracketed_sym_name(sym_name::in, needs_quotes::in,
     io::di, io::uo) is det.
+:- func mercury_bracketed_sym_name_to_string(sym_name, needs_quotes) = string.
 
 :- pred mercury_convert_var_name(string::in, string::out) is det.
 
@@ -3746,8 +3748,14 @@
 mercury_output_bracketed_sym_name(SymName, !IO) :-
     mercury_output_bracketed_sym_name(SymName, not_next_to_graphic_token, !IO).
 
+mercury_bracketed_sym_name_to_string(Name) =
+    mercury_bracketed_sym_name_to_string(Name, not_next_to_graphic_token).
+
 mercury_output_bracketed_sym_name(Name, NextToGraphicToken, !IO) :-
     mercury_format_bracketed_sym_name(Name, NextToGraphicToken, !IO).
+
+mercury_bracketed_sym_name_to_string(Name, NextToGraphicToken) = Str :-
+    mercury_format_bracketed_sym_name(Name, NextToGraphicToken, "", Str).
 
 :- pred mercury_format_bracketed_sym_name(sym_name::in,
     U::di, U::uo) is det <= output(U).
Index: compiler/mode_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.87
diff -u -b -r1.87 mode_errors.m
--- compiler/mode_errors.m	18 Aug 2005 07:57:51 -0000	1.87
+++ compiler/mode_errors.m	20 Aug 2005 12:10:11 -0000
@@ -224,105 +224,120 @@
 :- import_module varset.
 
 report_mode_error(ModeError, ModeInfo, !IO) :-
+    Specs = mode_error_to_specs(ModeError, ModeInfo),
+    write_error_specs(Specs, !IO).
+
+:- func mode_error_to_specs(mode_error::in, mode_info::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
+
+mode_error_to_specs(ModeError, ModeInfo) = Specs :-
     (
         ModeError = mode_error_disj(MergeContext, ErrorList),
-        report_mode_error_disj(ModeInfo, MergeContext, ErrorList, !IO)
+        Specs = mode_error_disj_to_specs(ModeInfo, MergeContext, ErrorList)
     ;
         ModeError = mode_error_par_conj(ErrorList),
-        report_mode_error_par_conj(ModeInfo, ErrorList, !IO)
+        Specs = mode_error_par_conj_to_specs(ModeInfo, ErrorList)
     ;
         ModeError = mode_error_higher_order_pred_var(PredOrFunc, Var, Inst,
             Arity),
-        report_mode_error_higher_order_pred_var(ModeInfo, PredOrFunc, Var,
-            Inst, Arity, !IO)
+        Specs = mode_error_higher_order_pred_var_to_specs(ModeInfo, PredOrFunc,
+            Var, Inst, Arity)
     ;
         ModeError = mode_error_poly_unify(Var, Inst),
-        report_mode_error_poly_unify(ModeInfo, Var, Inst, !IO)
+        Specs = mode_error_poly_unify_to_specs(ModeInfo, Var, Inst)
     ;
         ModeError = mode_error_var_is_live(Var),
-        report_mode_error_var_is_live(ModeInfo, Var, !IO)
+        Specs = mode_error_var_is_live_to_specs(ModeInfo, Var)
     ;
         ModeError = mode_error_var_has_inst(Var, InstA, InstB),
-        report_mode_error_var_has_inst(ModeInfo, Var, InstA, InstB, !IO)
+        Specs = mode_error_var_has_inst_to_specs(ModeInfo, Var, InstA, InstB)
     ;
         ModeError = mode_error_unify_pred(Var, RHS, Type, PredOrFunc),
-        report_mode_error_unify_pred(ModeInfo, Var, RHS, Type, PredOrFunc, !IO)
+        Specs = mode_error_unify_pred_to_specs(ModeInfo, Var, RHS, Type,
+            PredOrFunc)
     ;
         ModeError = mode_error_implied_mode(Var, InstA, InstB),
-        report_mode_error_implied_mode(ModeInfo, Var, InstA, InstB, !IO)
+        Specs = mode_error_implied_mode_to_specs(ModeInfo, Var, InstA, InstB)
     ;
         ModeError = mode_error_no_mode_decl,
-        report_mode_error_no_mode_decl(ModeInfo, !IO)
+        Specs = mode_error_no_mode_decl_to_specs(ModeInfo)
     ;
         ModeError = mode_error_bind_var(Reason, Var, InstA, InstB),
-        report_mode_error_bind_var(ModeInfo, Reason, Var, InstA, InstB, !IO)
+        Specs = mode_error_bind_var_to_specs(ModeInfo, Reason, Var,
+            InstA, InstB)
     ;
         ModeError = mode_error_non_local_lambda_var(Var, Inst),
-        report_mode_error_non_local_lambda_var(ModeInfo, Var, Inst, !IO)
+        Specs = mode_error_non_local_lambda_var_to_specs(ModeInfo, Var, Inst)
     ;
         ModeError = mode_error_unify_var_var(VarA, VarB, InstA, InstB),
-        report_mode_error_unify_var_var(ModeInfo, VarA, VarB, InstA, InstB,
-            !IO)
+        Specs = mode_error_unify_var_var_to_specs(ModeInfo, VarA, VarB,
+            InstA, InstB)
     ;
         ModeError = mode_error_unify_var_lambda(VarA, InstA, InstB),
-        report_mode_error_unify_var_lambda(ModeInfo, VarA, InstA, InstB, !IO)
+        Specs = mode_error_unify_var_lambda_to_specs(ModeInfo, VarA,
+            InstA, InstB)
     ;
         ModeError = mode_error_unify_var_functor(Var, Name, Args, Inst,
             ArgInsts),
-        report_mode_error_unify_var_functor(ModeInfo, Var, Name, Args, Inst,
-            ArgInsts, !IO)
+        Specs = mode_error_unify_var_functor_to_specs(ModeInfo, Var, Name,
+            Args, Inst, ArgInsts)
     ;
         ModeError = mode_error_conj(Errors, Culprit),
-        report_mode_error_conj(ModeInfo, Errors, Culprit, !IO)
+        Specs = mode_error_conj_to_specs(ModeInfo, Errors, Culprit)
     ;
         ModeError = mode_error_no_matching_mode(Vars, Insts),
-        report_mode_error_no_matching_mode(ModeInfo, Vars, Insts, !IO)
+        Specs = mode_error_no_matching_mode_to_specs(ModeInfo, Vars, Insts)
     ;
         ModeError = mode_error_in_callee(Vars, Insts,
             CalleePredId, CalleeProcId, CalleeErrors),
-        report_mode_error_in_callee(ModeInfo, Vars, Insts,
-            CalleePredId, CalleeProcId, CalleeErrors, !IO)
+        Specs = mode_error_in_callee_to_specs(ModeInfo, Vars, Insts,
+            CalleePredId, CalleeProcId, CalleeErrors)
     ;
         ModeError = mode_error_final_inst(ArgNum, Var, VarInst, Inst, Reason),
-        report_mode_error_final_inst(ModeInfo, ArgNum, Var, VarInst, Inst,
-            Reason, !IO)
+        Specs = mode_error_final_inst_to_specs(ModeInfo, ArgNum, Var, VarInst,
+            Inst, Reason)
     ).
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_conj(mode_info::in, list(delayed_goal)::in,
-    schedule_culprit::in, io::di, io::uo) is det.
+:- func mode_error_conj_to_specs(mode_info::in, list(delayed_goal)::in,
+    schedule_culprit::in) = (list(error_msg_spec)::out(error_msg_specs))
+    is det.
 
-report_mode_error_conj(ModeInfo, Errors, Culprit, !IO) :-
+mode_error_conj_to_specs(ModeInfo, Errors, Culprit) = Specs :-
     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.
-    globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
+    mode_info_get_module_info(ModeInfo, ModuleInfo),
+    module_info_globals(ModuleInfo, Globals),
+    globals__lookup_bool_option(Globals, verbose_errors, VerboseErrors),
     (
         VerboseErrors = yes,
         Errors = [_, _ | _]
     ->
-        mode_info_write_context(ModeInfo, !IO),
         PiecesA = [words("mode error in conjunction. The next"),
             fixed(int_to_string(list__length(Errors))),
             words("error messages indicate possible causes of this error.")],
-        write_error_pieces_not_first_line(Context, 0, PiecesA, !IO),
-        list__foldl(report_mode_error_conjunct(VarSet, Context, ModeInfo),
-            ImportantErrors ++ OtherErrors, !IO)
+        Specs1Start = [mode_info_context_to_spec(ModeInfo),
+            error_msg_spec(no, Context, 0, PiecesA)],
+        Specs1Rest = list__map(
+            mode_error_conjunct_to_specs(VarSet, Context, ModeInfo),
+            ImportantErrors ++ OtherErrors),
+        Specs1 = Specs1Start ++ list__condense(Specs1Rest)
     ;
         % In the normal case, only report the first error.
         ImportantErrors = [FirstImportantError | _]
     ->
-        report_mode_error_conjunct(VarSet, Context, ModeInfo,
-            FirstImportantError, !IO)
+        Specs1 = mode_error_conjunct_to_specs(VarSet, Context, ModeInfo,
+            FirstImportantError)
     ;
         OtherErrors = [FirstOtherError | _]
     ->
-        report_mode_error_conjunct(VarSet, Context, ModeInfo, FirstOtherError,
-            !IO)
+        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")
@@ -331,23 +346,25 @@
     % If the goal(s) couldn't be scheduled because we couldn't reorder things
     % past an impure goal, then report that.
     (
-        Culprit = conj_floundered
+        Culprit = conj_floundered,
         % We've already reported everything we can.
+        Specs2 = []
     ;
         Culprit = goal_itself_was_impure,
         Pieces = [words("The goal could not be reordered,"),
             words("because it was impure.")],
-        write_error_pieces_not_first_line(Context, 0, Pieces, !IO)
+        Specs2 = [error_msg_spec(no, Context, 0, Pieces)]
     ;
         Culprit = goals_followed_by_impure_goal(ImpureGoal),
-        Pieces1 = [words("The goal could not be reordered,"),
-            words("becaise it was followed by an impure goal.")],
-        write_error_pieces_not_first_line(Context, 0, Pieces1, !IO),
         ImpureGoal = _ - ImpureGoalInfo,
         goal_info_get_context(ImpureGoalInfo, ImpureGoalContext),
+        Pieces1 = [words("The goal could not be reordered,"),
+            words("becaise it was followed by an impure goal.")],
         Pieces2 = [words("This is the location of the impure goal.")],
-        write_error_pieces_not_first_line(ImpureGoalContext, 0, Pieces2, !IO)
-    ).
+        Specs2 = [error_msg_spec(no, Context, 0, Pieces1),
+            error_msg_spec(no, ImpureGoalContext, 0, Pieces2)]
+    ),
+    Specs = Specs1 ++ Specs2.
 
 :- pred is_error_important(delayed_goal::in) is semidet.
 
@@ -368,72 +385,83 @@
         true
     ).
 
-:- pred report_mode_error_conjunct(prog_varset::in, prog_context::in,
-    mode_info::in, delayed_goal::in, io::di, io::uo) is det.
-
-report_mode_error_conjunct(VarSet, Context, !.ModeInfo,
-        delayed_goal(Vars, Error, Goal), !IO) :-
-    globals__io_lookup_bool_option(debug_modes, Debug, !IO),
+:- func mode_error_conjunct_to_specs(prog_varset::in, prog_context::in,
+    mode_info::in, delayed_goal::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
+
+mode_error_conjunct_to_specs(VarSet, Context, !.ModeInfo, DelayedGoal)
+        = Specs :-
+    DelayedGoal = delayed_goal(Vars, Error, Goal),
+    mode_info_get_module_info(!.ModeInfo, ModuleInfo),
+    module_info_globals(ModuleInfo, Globals),
+    globals__lookup_bool_option(Globals, debug_modes, Debug),
     (
         Debug = yes,
-        prog_out__write_context(Context, !IO),
-        io__write_string("Floundered goal, waiting on { ", !IO),
         set__to_sorted_list(Vars, VarList),
-        mercury_output_vars(VarList, VarSet, no, !IO),
-        io__write_string(" } :\n", !IO)
+        Pieces1 = [words("Floundered goal, waiting on { "),
+            words(mercury_vars_to_string(VarList, VarSet, no)),
+            words(" } :"), nl],
+        Specs1 = [error_msg_spec(no, Context, 0, Pieces1)]
     ;
-        Debug = no
+        Debug = no,
+        Specs1 = []
     ),
-    globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
+    globals__lookup_bool_option(Globals, very_verbose, VeryVerbose),
     (
         VeryVerbose = yes,
-        mode_info_get_module_info(!.ModeInfo, ModuleInfo),
-        io__write_string("\t\t", !IO),
-        hlds_out__write_goal(Goal, ModuleInfo, VarSet, no, 2, ".\n", !IO)
+        Specs2 = [anything(write_indented_goal(Goal, ModuleInfo, VarSet))]
     ;
-        VeryVerbose = no
+        VeryVerbose = no,
+        Specs2 = []
     ),
     Error = mode_error_info(_, ModeError, ErrorContext, ModeContext),
     mode_info_set_context(ErrorContext, !ModeInfo),
     mode_info_set_mode_context(ModeContext, !ModeInfo),
-    report_mode_error(ModeError, !.ModeInfo, !IO).
+    Specs = Specs1 ++ Specs2 ++ mode_error_to_specs(ModeError, !.ModeInfo).
+
+:- pred write_indented_goal(hlds_goal::in, module_info::in, prog_varset::in,
+    io::di, io::uo) is det.
+
+write_indented_goal(Goal, ModuleInfo, VarSet, !IO) :-
+    io__write_string("\t\t", !IO),
+    hlds_out__write_goal(Goal, ModuleInfo, VarSet, no, 2, ".\n", !IO).
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_disj(mode_info::in, merge_context::in,
-    merge_errors::in, io::di, io::uo) is det.
+:- func mode_error_disj_to_specs(mode_info::in, merge_context::in,
+    merge_errors::in) = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_disj(ModeInfo, MergeContext, ErrorList, !IO) :-
-    mode_info_write_context(ModeInfo, !IO),
+mode_error_disj_to_specs(ModeInfo, MergeContext, ErrorList) = Specs :-
+    mode_info_get_context(ModeInfo, Context),
     Pieces = [words("mode mismatch in "),
         words(merge_context_to_string(MergeContext)), suffix(".")],
-    mode_info_get_context(ModeInfo, Context),
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO),
-    io__write_list(ErrorList, "", write_merge_error(ModeInfo), !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces) |
+        list__map(merge_error_to_spec(ModeInfo), ErrorList)].
 
-:- pred report_mode_error_par_conj(mode_info::in, merge_errors::in,
-    io::di, io::uo) is det.
+:- func mode_error_par_conj_to_specs(mode_info::in, merge_errors::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_par_conj(ModeInfo, ErrorList, !IO) :-
+mode_error_par_conj_to_specs(ModeInfo, ErrorList) = Specs :-
     mode_info_get_context(ModeInfo, Context),
-    mode_info_write_context(ModeInfo, !IO),
     Pieces = [words("mode error: mutually exclusive bindings"),
         words("in parallel conjunction."),
         words("(The current implementation does not permit"),
         words("parallel conjunctions to fail.)"), nl],
-    write_error_pieces_not_first_line(Context, 1, Pieces, !IO),
-    io__write_list(ErrorList, "", write_merge_error(ModeInfo), !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces) |
+        list__map(merge_error_to_spec(ModeInfo), ErrorList)].
 
-:- pred write_merge_error(mode_info::in, merge_error::in, io::di, io::uo)
-    is det.
+:- func merge_error_to_spec(mode_info::in, merge_error::in)
+    = (error_msg_spec::out(error_msg_spec)) is det.
 
-write_merge_error(ModeInfo, Var - Insts, !IO) :-
+merge_error_to_spec(ModeInfo, Var - Insts) = Spec :-
     mode_info_get_context(ModeInfo, Context),
     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],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Spec = error_msg_spec(no, Context, 0, Pieces).
 
 :- func merge_context_to_string(merge_context) = string.
 
@@ -442,13 +470,13 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_bind_var(mode_info::in, var_lock_reason::in,
-    prog_var::in, (inst)::in, (inst)::in, io::di, io::uo) is det.
+:- func mode_error_bind_var_to_specs(mode_info::in, var_lock_reason::in,
+    prog_var::in, (inst)::in, (inst)::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_bind_var(ModeInfo, Reason, Var, VarInst, Inst, !IO) :-
+mode_error_bind_var_to_specs(ModeInfo, Reason, Var, VarInst, Inst) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     (
         Reason = negation,
         ReasonStr = "attempt to bind a variable inside a negation."
@@ -473,7 +501,9 @@
         words(add_quotes(inst_to_string(ModeInfo, VarInst))), suffix(","), nl,
         words("expected instantiatedness was"),
         words(add_quotes(inst_to_string(ModeInfo, Inst))), suffix("."), nl],
-    globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
+    mode_info_get_module_info(ModeInfo, ModuleInfo),
+    module_info_globals(ModuleInfo, Globals),
+    globals__lookup_bool_option(Globals, verbose_errors, VerboseErrors),
     (
         VerboseErrors = yes,
         (
@@ -502,17 +532,17 @@
         VerboseErrors = no,
         Pieces2 = []
     ),
-    write_error_pieces_not_first_line(Context, 0, Pieces1 ++ Pieces2, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2)].
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_non_local_lambda_var(mode_info::in, prog_var::in,
-    (inst)::in, io::di, io::uo) is det.
+:- func mode_error_non_local_lambda_var_to_specs(mode_info::in, prog_var::in,
+    (inst)::in) = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_non_local_lambda_var(ModeInfo, Var, VarInst, !IO) :-
+mode_error_non_local_lambda_var_to_specs(ModeInfo, Var, VarInst) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     Pieces = [words("mode error: variable"),
         fixed(add_quotes(mercury_var_to_string(Var, VarSet, no))),
         words("has instantiatedness"),
@@ -520,26 +550,27 @@
         suffix(","), nl,
         words("expected instantiatedness for non-local variables"),
         words("of lambda goals is `ground'."), nl],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_in_callee(mode_info::in, list(prog_var)::in,
-    list(inst)::in, pred_id::in, proc_id::in, list(mode_error_info)::in,
-    io::di, io::uo) is det.
+:- func mode_error_in_callee_to_specs(mode_info::in, list(prog_var)::in,
+    list(inst)::in, pred_id::in, proc_id::in, list(mode_error_info)::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_in_callee(!.ModeInfo, Vars, Insts,
-        CalleePredId, CalleeProcId, CalleeModeErrors, !IO) :-
+mode_error_in_callee_to_specs(!.ModeInfo, Vars, Insts,
+        CalleePredId, CalleeProcId, CalleeModeErrors) = Specs :-
     mode_info_get_module_info(!.ModeInfo, ModuleInfo),
     mode_info_get_context(!.ModeInfo, Context),
     mode_info_get_varset(!.ModeInfo, VarSet),
-    mode_info_write_context(!.ModeInfo, !IO),
     Pieces1 = [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")],
-    globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
+    module_info_globals(ModuleInfo, Globals),
+    globals__lookup_bool_option(Globals, verbose_errors, VerboseErrors),
     (
         VerboseErrors = yes,
         Pieces2 = [words("the callee"), prefix("(")] ++
@@ -550,7 +581,8 @@
         VerboseErrors = no,
         Pieces2 = [words("the callee, because of the following error."), nl]
     ),
-    write_error_pieces_not_first_line(Context, 0, Pieces1 ++ Pieces2, !IO),
+    InitSpecs = [mode_info_context_to_spec(!.ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2)],
     (
         CalleeModeErrors = [First | _],
         First = mode_error_info(_, CalleeModeError,
@@ -559,17 +591,31 @@
         mode_info_set_procid(CalleeProcId, !ModeInfo),
         mode_info_set_context(CalleeContext, !ModeInfo),
         mode_info_set_mode_context(CalleeModeContext, !ModeInfo),
-        report_mode_error(CalleeModeError, !.ModeInfo, !IO)
+        LaterSpecs0 = mode_error_to_specs(CalleeModeError, !.ModeInfo),
+        (
+            LaterSpecs0 = [],
+            LaterSpecs = []
+        ;
+            LaterSpecs0 = [LaterSpecsHead0 | LaterSpecsTail],
+            (
+                LaterSpecsHead0 = error_msg_spec(_, _, _, _),
+                LaterSpecsHead = LaterSpecsHead0 ^ spec_treat_as_first := yes
+            ;
+                LaterSpecsHead0 = anything(_),
+                LaterSpecsHead = LaterSpecsHead0
+            ),
+            LaterSpecs = [LaterSpecsHead | LaterSpecsTail]
+        ),
+        Specs = InitSpecs ++ LaterSpecs
     ;
         CalleeModeErrors = [],
         error("report_mode_error_in_callee: no error")
     ).
 
-:- pred report_mode_error_no_matching_mode(mode_info::in, list(prog_var)::in,
-    list(inst)::in, io::di, io::uo) is det.
+:- func mode_error_no_matching_mode_to_specs(mode_info::in, list(prog_var)::in,
+    list(inst)::in) = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_no_matching_mode(ModeInfo, Vars, Insts, !IO) :-
-    mode_info_write_context(ModeInfo, !IO),
+mode_error_no_matching_mode_to_specs(ModeInfo, Vars, Insts) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
     mode_info_get_mode_context(ModeInfo, ModeContext),
@@ -585,16 +631,17 @@
         inst_list_to_sep_lines(ModeInfo, Insts) ++
         [words("which does not match any of the modes for"),
         words(CallIdStr), suffix("."), nl],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
-:- pred report_mode_error_higher_order_pred_var(mode_info::in, pred_or_func::in,
-    prog_var::in, (inst)::in, arity::in, io::di, io::uo) is det.
+:- func mode_error_higher_order_pred_var_to_specs(mode_info::in,
+    pred_or_func::in, prog_var::in, (inst)::in, arity::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_higher_order_pred_var(ModeInfo, PredOrFunc, Var, VarInst,
-        Arity, !IO) :-
+mode_error_higher_order_pred_var_to_specs(ModeInfo, PredOrFunc, Var, VarInst,
+        Arity) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     (
         PredOrFunc = predicate,
         Expecting = "expecting higher-order pred inst (of arity " ++
@@ -610,22 +657,24 @@
         words(add_quotes(inst_to_string(ModeInfo, VarInst))),
         suffix(","), nl,
         words(Expecting), nl],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
-:- pred report_mode_error_poly_unify(mode_info::in, prog_var::in, (inst)::in,
-    io::di, io::uo) is det.
+:- func mode_error_poly_unify_to_specs(mode_info::in, prog_var::in, (inst)::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_poly_unify(ModeInfo, Var, VarInst, !IO) :-
+mode_error_poly_unify_to_specs(ModeInfo, Var, VarInst) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     Pieces1 = [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],
-    globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
+    mode_info_get_module_info(ModeInfo, ModuleInfo),
+    module_info_globals(ModuleInfo, Globals),
+    globals__lookup_bool_option(Globals, verbose_errors, VerboseErrors),
     (
         VerboseErrors = yes,
         Pieces2 = [words("When unifying two variables whose type"),
@@ -637,48 +686,52 @@
         VerboseErrors = no,
         Pieces2 = []
     ),
-    write_error_pieces_not_first_line(Context, 0, Pieces1 ++ Pieces2, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2)].
 
-:- pred report_mode_error_var_is_live(mode_info::in, prog_var::in,
-    io::di, io::uo) is det.
+:- func mode_error_var_is_live_to_specs(mode_info::in, prog_var::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_var_is_live(ModeInfo, Var, !IO) :-
+mode_error_var_is_live_to_specs(ModeInfo, Var) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     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],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
-:- pred report_mode_error_var_has_inst(mode_info::in, prog_var::in,
-    (inst)::in, (inst)::in, io::di, io::uo) is det.
+:- func mode_error_var_has_inst_to_specs(mode_info::in, prog_var::in,
+    (inst)::in, (inst)::in) = (list(error_msg_spec)::out(error_msg_specs))
+    is det.
 
-report_mode_error_var_has_inst(ModeInfo, Var, VarInst, Inst, !IO) :-
+mode_error_var_has_inst_to_specs(ModeInfo, Var, VarInst, Inst) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     Pieces = [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"),
         words(add_quotes(inst_to_string(ModeInfo, Inst))), suffix("."), nl],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
-:- pred report_mode_error_implied_mode(mode_info::in, prog_var::in,
-    (inst)::in, (inst)::in, io::di, io::uo) is det.
+:- func mode_error_implied_mode_to_specs(mode_info::in, prog_var::in,
+    (inst)::in, (inst)::in) = (list(error_msg_spec)::out(error_msg_specs))
+    is det.
 
-report_mode_error_implied_mode(ModeInfo, Var, VarInst, Inst, !IO) :-
+mode_error_implied_mode_to_specs(ModeInfo, Var, VarInst, Inst) = Specs :-
         % This "error" message is really a "sorry, not implemented" message.
         % We only print the message if we will actually generating code.
-    globals__io_lookup_bool_option(errorcheck_only, ErrorcheckOnly, !IO),
+    mode_info_get_module_info(ModeInfo, ModuleInfo),
+    module_info_globals(ModuleInfo, Globals),
+    globals__lookup_bool_option(Globals, errorcheck_only, ErrorcheckOnly),
     (
         ErrorcheckOnly = no,
         mode_info_get_context(ModeInfo, Context),
         mode_info_get_varset(ModeInfo, VarSet),
-        mode_info_write_context(ModeInfo, !IO),
         Pieces = [words("sorry, implied modes not implemented."), nl,
             words("Variable"),
             words(add_quotes(mercury_var_to_string(Var, VarSet, no))),
@@ -688,83 +741,85 @@
             words("expected instantiatedness was"),
             words(add_quotes(inst_to_string(ModeInfo, Inst))),
             suffix("."), nl],
-        write_error_pieces_not_first_line(Context, 0, Pieces, !IO)
+        Specs = [mode_info_context_to_spec(ModeInfo),
+            error_msg_spec(no, Context, 0, Pieces)]
     ;
-        ErrorcheckOnly = yes
+        ErrorcheckOnly = yes,
+        Specs = []
     ).
 
-:- pred report_mode_error_no_mode_decl(mode_info::in, io::di, io::uo) is det.
+:- func mode_error_no_mode_decl_to_specs(mode_info::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_no_mode_decl(ModeInfo, !IO) :-
+mode_error_no_mode_decl_to_specs(ModeInfo) = Specs :-
     mode_info_get_context(ModeInfo, Context),
-    mode_info_write_context(ModeInfo, !IO),
     Pieces = [words("no mode declaration for called predicate."), nl],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
-:- pred report_mode_error_unify_pred(mode_info::in, prog_var::in,
-    mode_error_unify_rhs::in, (type)::in, pred_or_func::in,
-    io::di, io::uo) is det.
+:- func mode_error_unify_pred_to_specs(mode_info::in, prog_var::in,
+    mode_error_unify_rhs::in, (type)::in, pred_or_func::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_unify_pred(ModeInfo, X, RHS, Type, PredOrFunc) -->
-    { mode_info_get_context(ModeInfo, Context) },
-    { mode_info_get_varset(ModeInfo, VarSet) },
-    { mode_info_get_instvarset(ModeInfo, InstVarSet) },
-    mode_info_write_context(ModeInfo),
-    prog_out__write_context(Context),
-    io__write_string("  In unification of `"),
-    mercury_output_var(X, VarSet, no),
-    io__write_string("' with `"),
-    (
-        { RHS = error_at_var(Y) },
-        mercury_output_var(Y, VarSet, no)
-    ;
-        { RHS = error_at_functor(ConsId, ArgVars) },
-        { mode_info_get_module_info(ModeInfo, ModuleInfo) },
-        hlds_out__write_functor_cons_id(ConsId, ArgVars, VarSet,
+mode_error_unify_pred_to_specs(ModeInfo, X, RHS, Type, PredOrFunc) = Specs :-
+    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_globals(ModuleInfo, Globals),
+    (
+        RHS = error_at_var(Y),
+        RHSStr = mercury_var_to_string(Y, VarSet, no)
+    ;
+        RHS = error_at_functor(ConsId, ArgVars),
+        RHSStr = hlds_out__functor_cons_id_to_string(ConsId, ArgVars, VarSet,
             ModuleInfo, no)
     ;
-        { RHS = error_at_lambda(ArgVars, ArgModes) },
-        io__write_string("lambda(["),
-        hlds_out__write_var_modes(ArgVars, ArgModes, VarSet,
-            InstVarSet, no),
-        io__write_string("] ... )")
-    ),
-    io__write_string("':\n"),
-    prog_out__write_context(Context),
-    io__write_string("  mode error: attempt at higher-order unification.\n"),
-    prog_out__write_context(Context),
-    io__write_string("  Cannot unify two terms of type `"),
-    { varset__init(TypeVarSet) },
-    mercury_output_term(Type, TypeVarSet, no),
-    io__write_string("'.\n"),
-    globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
-    ( { VerboseErrors = yes } ->
-        io__write_string("\tYour code is trying to test whether two "),
-        prog_out__write_pred_or_func(PredOrFunc),
-        io__write_string("s are equal,\n"),
-        io__write_string("\tby unifying them.  In the general " ++
-                    "case, testing equivalence\n"),
-        io__write_string("\tof "),
-        prog_out__write_pred_or_func(PredOrFunc),
-        io__write_string("s is an undecidable problem,\n"),
-        io__write_string("\tand so this is not allowed by the Mercury mode system.\n"),
-        io__write_string("\tIn some cases, you can achieve the same effect by\n"),
-        io__write_string("\twriting an explicit universal quantification,\n"),
-        io__write_string("\te.g. `all [X] call(P, X) <=> call(Q, X)',"),
-        io__write_string(" instead of `P = Q'.\n")
+        RHS = error_at_lambda(ArgVars, ArgModes),
+        RHSStr = "lambda(["
+            ++ hlds_out__var_modes_to_string(ArgVars, ArgModes, VarSet,
+                InstVarSet, no)
+            ++ "] ... )"
+    ),
+    varset__init(TypeVarSet),
+    Pieces1 = [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_term_to_string(Type, TypeVarSet, no))),
+        suffix("."), nl],
+    globals__lookup_bool_option(Globals, verbose_errors, VerboseErrors),
+    (
+        VerboseErrors = yes,
+        Pieces2 = [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"),
+            words(prog_out__pred_or_func_to_full_str(PredOrFunc) ++ "s"),
+            words("is an undecidable problem,"),
+            words("and so this is not allowed by the Mercury mode system."),
+            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)].
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_unify_var_var(mode_info::in, prog_var::in,
-    prog_var::in, (inst)::in, (inst)::in, io::di, io::uo) is det.
+:- func mode_error_unify_var_var_to_specs(mode_info::in, prog_var::in,
+    prog_var::in, (inst)::in, (inst)::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_unify_var_var(ModeInfo, X, Y, InstX, InstY, !IO) :-
+mode_error_unify_var_var_to_specs(ModeInfo, X, Y, InstX, InstY) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     Pieces = [words("mode error in unification of"),
         words(add_quotes(mercury_var_to_string(X, VarSet, no))),
         words("and"),
@@ -778,17 +833,18 @@
         words(add_quotes(mercury_var_to_string(Y, VarSet, no))),
         words("has instantiatedness"),
         words(add_quotes(inst_to_string(ModeInfo, InstY))), suffix("."), nl],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_unify_var_lambda(mode_info::in, prog_var::in,
-    (inst)::in, (inst)::in, io::di, io::uo) is det.
+:- func mode_error_unify_var_lambda_to_specs(mode_info::in, prog_var::in,
+    (inst)::in, (inst)::in) = (list(error_msg_spec)::out(error_msg_specs))
+    is det.
 
-report_mode_error_unify_var_lambda(ModeInfo, X, InstX, InstY, !IO) :-
+mode_error_unify_var_lambda_to_specs(ModeInfo, X, InstX, InstY) = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     Pieces = [words("mode error in unification of"),
         words(add_quotes(mercury_var_to_string(X, VarSet, no))),
         words("and lambda expression."), nl,
@@ -798,57 +854,55 @@
         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],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_unify_var_functor(mode_info::in, prog_var::in,
-    cons_id::in, list(prog_var)::in, (inst)::in, list(inst)::in,
-    io::di, io::uo) is det.
+:- func mode_error_unify_var_functor_to_specs(mode_info::in, prog_var::in,
+    cons_id::in, list(prog_var)::in, (inst)::in, list(inst)::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
 
-report_mode_error_unify_var_functor(ModeInfo, X, ConsId, Args, InstX, ArgInsts)
-        -->
-    { mode_info_get_context(ModeInfo, Context) },
-    { mode_info_get_varset(ModeInfo, VarSet) },
-    { mode_info_get_module_info(ModeInfo, ModuleInfo) },
-    mode_info_write_context(ModeInfo),
-    prog_out__write_context(Context),
-    io__write_string("  mode error in unification of `"),
-    mercury_output_var(X, VarSet, no),
-    io__write_string("' and `"),
-    hlds_out__write_functor_cons_id(ConsId, Args, VarSet, ModuleInfo, no),
-    io__write_string("'.\n"),
-    prog_out__write_context(Context),
-    io__write_string("  Variable `"),
-    mercury_output_var(X, VarSet, no),
-    io__write_string("' has instantiatedness `"),
-    output_inst(InstX, ModeInfo),
-    io__write_string("',\n"),
-    prog_out__write_context(Context),
-    io__write_string("  term `"),
-    hlds_out__write_functor_cons_id(ConsId, Args, VarSet, ModuleInfo, no),
-    (
-        { Args = [_ | _] },
-        io__write_string("'\n"),
-        prog_out__write_context(Context),
-        io__write_string("  has instantiatedness `"),
-        mercury_output_cons_id(ConsId, does_not_need_brackets),
-        io__write_string("(\n"),
-        output_inst_list_sep_lines(Context, ArgInsts, ModeInfo),
-        prog_out__write_context(Context),
-        io__write_string("  )")
-    ;
-        { Args = [] },
-        io__write_string("' has instantiatedness `"),
-        mercury_output_cons_id(ConsId, does_not_need_brackets)
+mode_error_unify_var_functor_to_specs(ModeInfo, X, ConsId, Args,
+        InstX, ArgInsts) = Specs :-
+    mode_info_get_context(ModeInfo, Context),
+    mode_info_get_varset(ModeInfo, VarSet),
+    mode_info_get_module_info(ModeInfo, ModuleInfo),
+    Pieces1 = [words("mode error in unification of"),
+        words(add_quotes(mercury_var_to_string(X, VarSet, no))),
+        words("and"),
+        words(add_quotes(hlds_out__functor_cons_id_to_string(ConsId, Args,
+            VarSet, ModuleInfo, no))), suffix("."), nl,
+        words("Variable"),
+        words(add_quotes(mercury_var_to_string(X, VarSet, no))),
+        words("has instantiatedness"),
+        words(add_quotes(inst_to_string(ModeInfo, InstX))), suffix(","), nl,
+        words("term"),
+        words(add_quotes(hlds_out__functor_cons_id_to_string(ConsId, Args,
+            VarSet, ModuleInfo, no)))],
+    (
+        Args = [_ | _],
+        Pieces2 = [words("has instantiatedness"),
+            prefix("`"),
+            words(mercury_cons_id_to_string(ConsId, does_not_need_brackets)),
+            suffix("("), nl_indent_delta(1)] ++
+            inst_list_to_sep_lines(ModeInfo, ArgInsts) ++
+            [fixed(")'.")]
+    ;
+        Args = [],
+        Pieces2 = [words("has instantiatedness"),
+            words(add_quotes(mercury_cons_id_to_string(ConsId,
+                does_not_need_brackets))), suffix("."), nl]
     ),
-    io__write_string("'.\n").
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2)].
 
 %-----------------------------------------------------------------------------%
 
-:- pred mode_info_write_context(mode_info::in, io::di, io::uo) is det.
+:- func mode_info_context_to_spec(mode_info::in)
+    = (error_msg_spec::out(error_msg_spec)) is det.
 
-mode_info_write_context(ModeInfo, !IO) :-
+mode_info_context_to_spec(ModeInfo) = Spec :-
     mode_info_get_module_info(ModeInfo, ModuleInfo),
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_predid(ModeInfo, PredId),
@@ -864,24 +918,43 @@
     mode_info_get_instvarset(ModeInfo, InstVarSet),
     MaybeDet = no,
 
-    prog_out__write_context(Context, !IO),
-    io__write_string("In clause for `", !IO),
-    mercury_output_mode_subdecl(PredOrFunc, InstVarSet, Name, Modes,
-        MaybeDet, Context, !IO),
-    io__write_string("':\n", !IO),
+    ModeSubDeclStr = mercury_mode_subdecl_to_string(PredOrFunc, InstVarSet,
+        Name, Modes, MaybeDet, Context),
+    Pieces1 = [words("In clause for"),
+        words(add_quotes(ModeSubDeclStr)), suffix(":"), nl],
     mode_info_get_mode_context(ModeInfo, ModeContext),
-    write_mode_context(ModeContext, Context, PredMarkers, !IO).
+    Pieces2 = mode_context_to_pieces(ModeContext, PredMarkers),
+    Spec = error_msg_spec(no, Context, 0, Pieces1 ++ Pieces2).
 
 %-----------------------------------------------------------------------------%
 
-:- pred report_mode_error_final_inst(mode_info::in, int::in, prog_var::in,
-    (inst)::in, (inst)::in, final_inst_error::in, io::di, io::uo) is det.
+    % XXX some parts of the mode context never get set up
 
-report_mode_error_final_inst(ModeInfo, ArgNum, Var, VarInst, Inst, Reason,
-        !IO) :-
+:- func mode_context_to_pieces(mode_context, pred_markers)
+    = list(format_component).
+
+mode_context_to_pieces(uninitialized, _Markers) = [].
+mode_context_to_pieces(call(CallId, ArgNum), Markers) =
+    [words("in"),
+        words(hlds_out__call_arg_id_to_string(CallId, ArgNum, Markers)),
+        suffix(":"), nl].
+mode_context_to_pieces(unify(UnifyContext, _Side), _Markers) = Pieces :-
+    hlds_out__unify_context_to_pieces(no, _, UnifyContext, [], Pieces).
+
+%-----------------------------------------------------------------------------%
+
+mode_context_init(uninitialized).
+
+%-----------------------------------------------------------------------------%
+
+:- func mode_error_final_inst_to_specs(mode_info::in, int::in, prog_var::in,
+    (inst)::in, (inst)::in, final_inst_error::in)
+    = (list(error_msg_spec)::out(error_msg_specs)) is det.
+
+mode_error_final_inst_to_specs(ModeInfo, ArgNum, Var, VarInst, Inst, Reason)
+        = Specs :-
     mode_info_get_context(ModeInfo, Context),
     mode_info_get_varset(ModeInfo, VarSet),
-    mode_info_write_context(ModeInfo, !IO),
     ( Reason = too_instantiated ->
         Problem = " became too instantiated."
     ; Reason = not_instantiated_enough ->
@@ -899,27 +972,8 @@
         words("expected final instantiatedness was"),
         words(add_quotes(inst_to_string(ModeInfo, Inst))),
         suffix("."), nl],
-    write_error_pieces_not_first_line(Context, 0, Pieces, !IO).
-
-%-----------------------------------------------------------------------------%
-
-mode_context_init(uninitialized).
-
-%-----------------------------------------------------------------------------%
-
-    % XXX some parts of the mode context never get set up
-
-:- pred write_mode_context(mode_context::in, prog_context::in,
-    pred_markers::in, io::di, io::uo) is det.
-
-write_mode_context(uninitialized, _Context, _Markers, !IO).
-write_mode_context(call(CallId, ArgNum), Context, Markers, !IO) :-
-    prog_out__write_context(Context, !IO),
-    io__write_string("  in ", !IO),
-    hlds_out__write_call_arg_id(CallId, ArgNum, Markers, !IO),
-    io__write_string(":\n", !IO).
-write_mode_context(unify(UnifyContext, _Side), Context, _Markers, !IO) :-
-    hlds_out__write_unify_context(UnifyContext, Context, !IO).
+    Specs = [mode_info_context_to_spec(ModeInfo),
+        error_msg_spec(no, Context, 0, Pieces)].
 
 %-----------------------------------------------------------------------------%
 
@@ -1077,7 +1131,7 @@
     mode_info_get_errors(!.ModeInfo, Errors),
     (
         Errors = [FirstError | _],
-        % XXX Why do we only report the first?
+        % 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),
@@ -1101,7 +1155,7 @@
     Pieces1 = [words("In mode declarations for ")] ++
         describe_one_pred_name(ModuleInfo, should_module_qualify, PredId)
         ++ [suffix(":"), nl, words("error: duplicate mode declaration."), nl],
-    write_error_pieces(NewContext, 0, Pieces1, !IO),
+    Specs1 = [error_msg_spec(no, NewContext, 0, Pieces1)],
 
     globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
     (
@@ -1111,13 +1165,23 @@
             words("and"),
             fixed(add_quotes(mode_decl_to_string(NewProcId, PredInfo))),
             words("are indistinguishable.")],
-        write_error_pieces_not_first_line(NewContext, 0, Pieces2, !IO)
+        Specs2 = [error_msg_spec(no, NewContext, 0, Pieces2)]
     ;
-        VerboseErrors = no
+        VerboseErrors = no,
+        Specs2 = []
     ),
 
     Pieces3 = [words("Here is the conflicting mode declaration.")],
-    write_error_pieces_not_first_line(OldContext, 0, Pieces3, !IO).
+    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.
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/prog_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_out.m,v
retrieving revision 1.61
diff -u -b -r1.61 prog_out.m
--- compiler/prog_out.m	14 Aug 2005 03:20:41 -0000	1.61
+++ compiler/prog_out.m	20 Aug 2005 03:59:31 -0000
@@ -59,6 +59,7 @@
     % enclosing forward/backward-quote pair (`...').
     %
 :- pred write_sym_name(sym_name::in, io::di, io::uo) is det.
+:- func sym_name_to_escaped_string(sym_name) = string.
 
 :- pred write_sym_name_and_arity(sym_name_and_arity::in, io::di, io::uo)
     is det.
@@ -96,6 +97,7 @@
     % Write out a module specifier.
     %
 :- pred write_module_spec(module_specifier::in, io::di, io::uo) is det.
+:- func module_spec_to_escaped_string(module_specifier) = string.
 
 :- pred write_module_list(list(module_name)::in, io::di, io::uo) is det.
 
@@ -240,13 +242,20 @@
 
 %-----------------------------------------------------------------------------%
 
-write_sym_name(qualified(ModuleSpec,Name), !IO) :-
+write_sym_name(qualified(ModuleSpec, Name), !IO) :-
     write_module_spec(ModuleSpec, !IO),
     io__write_string(".", !IO),
     term_io__write_escaped_string(Name, !IO).
 write_sym_name(unqualified(Name), !IO) :-
     term_io__write_escaped_string(Name, !IO).
 
+sym_name_to_escaped_string(qualified(ModuleSpec, Name)) =
+    module_spec_to_escaped_string(ModuleSpec)
+    ++ "."
+    ++ term_io__escaped_string(Name).
+sym_name_to_escaped_string(unqualified(Name)) =
+    term_io__escaped_string(Name).
+
 write_sym_name_and_arity(Name / Arity, !IO) :-
     write_sym_name(Name, !IO),
     io__write_string("/", !IO),
@@ -324,6 +333,9 @@
 
 write_module_spec(ModuleSpec, !IO) :-
     write_sym_name(ModuleSpec, !IO).
+
+module_spec_to_escaped_string(ModuleSpec) =
+    sym_name_to_escaped_string(ModuleSpec).
 
 %-----------------------------------------------------------------------------%
 
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
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/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/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/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/term_io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/term_io.m,v
retrieving revision 1.74
diff -u -b -r1.74 term_io.m
--- library/term_io.m	16 Jun 2005 04:08:06 -0000	1.74
+++ library/term_io.m	21 Aug 2005 01:56:51 -0000
@@ -613,11 +613,18 @@
 :- func term_io__add_escaped_char(char, string) = string.
 
 term_io__add_escaped_char(Char, String0) = String :-
-	String = string__append(String0, string__char_to_string(Char)).
+	( mercury_escape_special_char(Char, QuoteChar) ->
+		String = String0 ++ from_char_list(['\\', QuoteChar])
+	; is_mercury_source_char(Char) ->
+		String = String0 ++ string__char_to_string(Char)
+	;
+		String = String0 ++ mercury_escape_char(Char)
+	).
 
-	% Note: the code here is similar to code in
-	% compiler/mercury_to_mercury.m; any changes here
-	% may require similar changes there.
+	% Note: the code of add_escaped_char and write_escaped_char should be
+	% kept in sync. The code of both is similar to code in
+	% compiler/mercury_to_mercury.m; any changes here may require
+	% similar changes there.
 
 term_io__write_escaped_char(Char, !IO) :-
 	( mercury_escape_special_char(Char, QuoteChar) ->
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/xmlable_test.exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/xmlable_test.exp,v
retrieving revision 1.1
diff -u -b -r1.1 xmlable_test.exp
--- tests/hard_coded/xmlable_test.exp	29 Jul 2005 01:57:00 -0000	1.1
+++ tests/hard_coded/xmlable_test.exp	21 Aug 2005 03:23:24 -0000
@@ -28,7 +28,7 @@
 			</tr>
 			<tr>
 				<td>6</td>
-				<td>"six &<>!@$%^`&*()-+='"</td>
+				<td>"six &<>!@$%^`&*()-+=\'"</td>
 			</tr>
 		</table><hr /> <!-- inline comment --><script type="text/javascript">
 			<![CDATA[document.write('hello');]]>
@@ -64,7 +64,7 @@
 			</tr>
 			<tr>
 				<td>6</td>
-				<td>"six &<>!@$%^`&*()-+='"</td>
+				<td>"six &<>!@$%^`&*()-+=\'"</td>
 			</tr>
 		</table><hr /> <!-- inline comment --><script type="text/javascript">
 			<![CDATA[document.write('hello');]]>
@@ -99,7 +99,7 @@
 					</tr>
 					<tr>
 						<td>6</td>
-						<td>"six &<>!@$%^`&*()-+='"</td>
+						<td>"six &<>!@$%^`&*()-+=\'"</td>
 					</tr>
 				</table><hr /> <!-- inline comment --><script type="text/javascript">
 					<![CDATA[document.write('hello');]]>
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/aditi_update_mode_errors.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/aditi_update_mode_errors.err_exp,v
retrieving revision 1.11
diff -u -b -r1.11 aditi_update_mode_errors.err_exp
--- tests/invalid/aditi_update_mode_errors.err_exp	18 Aug 2005 07:57:57 -0000	1.11
+++ tests/invalid/aditi_update_mode_errors.err_exp	20 Aug 2005 10:31:40 -0000
@@ -46,64 +46,93 @@
 aditi_update_mode_errors.m:105:   `aditi_update_mode_errors.aditi_update_modes11/2':
 aditi_update_mode_errors.m:105:   warning: variable `X0' occurs only once in
 aditi_update_mode_errors.m:105:   this scope.
-aditi_update_mode_errors.m:053: In clause for `aditi_update_modes1((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:053:   in argument 2 of the inserted tuple of `aditi_insert' of predicate `aditi_update_mode_errors.p/3':
+aditi_update_mode_errors.m:053: In clause for
+aditi_update_mode_errors.m:053:   `aditi_update_modes1((aditi.aditi_di),
+aditi_update_mode_errors.m:053:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:053:   in argument 2 of the inserted tuple of
+aditi_update_mode_errors.m:053:   `aditi_insert' of predicate
+aditi_update_mode_errors.m:053:   `aditi_update_mode_errors.p/3':
 aditi_update_mode_errors.m:053:   mode error: variable `V_4' has
 aditi_update_mode_errors.m:053:   instantiatedness `free',
 aditi_update_mode_errors.m:053:   expected instantiatedness was `ground'.
-aditi_update_mode_errors.m:056: In clause for `aditi_update_modes2((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:056:   in argument 2 of the inserted tuple of `aditi_insert' of function `aditi_update_mode_errors.q/2':
+aditi_update_mode_errors.m:056: In clause for
+aditi_update_mode_errors.m:056:   `aditi_update_modes2((aditi.aditi_di),
+aditi_update_mode_errors.m:056:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:056:   in argument 2 of the inserted tuple of
+aditi_update_mode_errors.m:056:   `aditi_insert' of function
+aditi_update_mode_errors.m:056:   `aditi_update_mode_errors.q/2':
 aditi_update_mode_errors.m:056:   mode error: variable `V_4' has
 aditi_update_mode_errors.m:056:   instantiatedness `free',
 aditi_update_mode_errors.m:056:   expected instantiatedness was `ground'.
-aditi_update_mode_errors.m:059: In clause for `aditi_update_modes3((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:059:   in argument 2 of `aditi_insert' of predicate `aditi_update_mode_errors.p/3':
+aditi_update_mode_errors.m:059: In clause for
+aditi_update_mode_errors.m:059:   `aditi_update_modes3((aditi.aditi_di),
+aditi_update_mode_errors.m:059:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:059:   in argument 2 of `aditi_insert' of predicate
+aditi_update_mode_errors.m:059:   `aditi_update_mode_errors.p/3':
 aditi_update_mode_errors.m:059:   mode error: variable `V_4' has
 aditi_update_mode_errors.m:059:   instantiatedness `free',
 aditi_update_mode_errors.m:059:   expected instantiatedness was `ground'.
-aditi_update_mode_errors.m:062: In clause for `aditi_update_modes4((aditi.aditi_di), (aditi.aditi_uo))':
+aditi_update_mode_errors.m:062: In clause for
+aditi_update_mode_errors.m:062:   `aditi_update_modes4((aditi.aditi_di),
+aditi_update_mode_errors.m:062:   (aditi.aditi_uo))':
 aditi_update_mode_errors.m:062:   in argument 1 of call to predicate `int.</2':
 aditi_update_mode_errors.m:062:   mode error: variable `X' has instantiatedness
 aditi_update_mode_errors.m:062:   `free',
 aditi_update_mode_errors.m:062:   expected instantiatedness was `ground'.
-aditi_update_mode_errors.m:065: In clause for `aditi_update_modes5((aditi.aditi_di), (aditi.aditi_uo))':
+aditi_update_mode_errors.m:065: In clause for
+aditi_update_mode_errors.m:065:   `aditi_update_modes5((aditi.aditi_di),
+aditi_update_mode_errors.m:065:   (aditi.aditi_uo))':
 aditi_update_mode_errors.m:065:   in argument 1 of call to predicate `int.</2':
 aditi_update_mode_errors.m:065:   mode error: variable `X' has instantiatedness
 aditi_update_mode_errors.m:065:   `free',
 aditi_update_mode_errors.m:065:   expected instantiatedness was `ground'.
-aditi_update_mode_errors.m:072: In clause for `aditi_update_modes6((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:072:   in argument 2 of `aditi_bulk_delete' of predicate `aditi_update_mode_errors.p/3':
+aditi_update_mode_errors.m:072: In clause for
+aditi_update_mode_errors.m:072:   `aditi_update_modes6((aditi.aditi_di),
+aditi_update_mode_errors.m:072:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:072:   in argument 2 of `aditi_bulk_delete' of
+aditi_update_mode_errors.m:072:   predicate `aditi_update_mode_errors.p/3':
 aditi_update_mode_errors.m:072:   mode error: variable `DeleteP' has
 aditi_update_mode_errors.m:072:   instantiatedness `/* unique */(pred((free >>
 aditi_update_mode_errors.m:072:   free), (free >> ground), (ground >> ground))
 aditi_update_mode_errors.m:072:   is nondet)',
 aditi_update_mode_errors.m:072:   expected instantiatedness was `(pred(in, out,
 aditi_update_mode_errors.m:072:   out) is nondet)'.
-aditi_update_mode_errors.m:078: In clause for `aditi_update_modes7((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:078:   in argument 2 of `aditi_bulk_delete' of function `aditi_update_mode_errors.q/2':
+aditi_update_mode_errors.m:078: In clause for
+aditi_update_mode_errors.m:078:   `aditi_update_modes7((aditi.aditi_di),
+aditi_update_mode_errors.m:078:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:078:   in argument 2 of `aditi_bulk_delete' of
+aditi_update_mode_errors.m:078:   function `aditi_update_mode_errors.q/2':
 aditi_update_mode_errors.m:078:   mode error: variable `DeleteQ' has
 aditi_update_mode_errors.m:078:   instantiatedness `/* unique */(func((free >>
 aditi_update_mode_errors.m:078:   free), (free >> ground)) = (ground >> ground)
 aditi_update_mode_errors.m:078:   is nondet)',
 aditi_update_mode_errors.m:078:   expected instantiatedness was `(func(in, out)
 aditi_update_mode_errors.m:078:   = out is nondet)'.
-aditi_update_mode_errors.m:087: In clause for `aditi_update_modes8((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:087:   in argument 2 of `aditi_bulk_insert' of predicate `aditi_update_mode_errors.p/3':
+aditi_update_mode_errors.m:087: In clause for
+aditi_update_mode_errors.m:087:   `aditi_update_modes8((aditi.aditi_di),
+aditi_update_mode_errors.m:087:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:087:   in argument 2 of `aditi_bulk_insert' of
+aditi_update_mode_errors.m:087:   predicate `aditi_update_mode_errors.p/3':
 aditi_update_mode_errors.m:087:   mode error: variable `InsertP' has
 aditi_update_mode_errors.m:087:   instantiatedness `/* unique */(pred((ground
 aditi_update_mode_errors.m:087:   >> ground), (ground >> ground), (free >>
 aditi_update_mode_errors.m:087:   ground)) is nondet)',
 aditi_update_mode_errors.m:087:   expected instantiatedness was `(pred(in, out,
 aditi_update_mode_errors.m:087:   out) is nondet)'.
-aditi_update_mode_errors.m:098: In clause for `aditi_update_modes9((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:098:   in argument 2 of `aditi_bulk_insert' of function `aditi_update_mode_errors.q/2':
+aditi_update_mode_errors.m:098: In clause for
+aditi_update_mode_errors.m:098:   `aditi_update_modes9((aditi.aditi_di),
+aditi_update_mode_errors.m:098:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:098:   in argument 2 of `aditi_bulk_insert' of
+aditi_update_mode_errors.m:098:   function `aditi_update_mode_errors.q/2':
 aditi_update_mode_errors.m:098:   mode error: variable `InsertQ' has
 aditi_update_mode_errors.m:098:   instantiatedness `/* unique */(func((ground
 aditi_update_mode_errors.m:098:   >> ground), (ground >> ground)) = (free >>
 aditi_update_mode_errors.m:098:   ground) is nondet)',
 aditi_update_mode_errors.m:098:   expected instantiatedness was `(func(in, out)
 aditi_update_mode_errors.m:098:   = out is nondet)'.
-aditi_update_mode_errors.m:102: In clause for `aditi_update_modes10((aditi.aditi_di), (aditi.aditi_uo))':
+aditi_update_mode_errors.m:102: In clause for
+aditi_update_mode_errors.m:102:   `aditi_update_modes10((aditi.aditi_di),
+aditi_update_mode_errors.m:102:   (aditi.aditi_uo))':
 aditi_update_mode_errors.m:102:   in call to function `int.+/2':
 aditi_update_mode_errors.m:102:   mode error: arguments `X0, V_12, V_10' have
 aditi_update_mode_errors.m:102:   the following insts:
@@ -112,7 +141,9 @@
 aditi_update_mode_errors.m:102:     free
 aditi_update_mode_errors.m:102:   which does not match any of the modes for
 aditi_update_mode_errors.m:102:   function `int.+/2'.
-aditi_update_mode_errors.m:105: In clause for `aditi_update_modes11((aditi.aditi_di), (aditi.aditi_uo))':
+aditi_update_mode_errors.m:105: In clause for
+aditi_update_mode_errors.m:105:   `aditi_update_modes11((aditi.aditi_di),
+aditi_update_mode_errors.m:105:   (aditi.aditi_uo))':
 aditi_update_mode_errors.m:105:   in call to function `int.+/2':
 aditi_update_mode_errors.m:105:   mode error: arguments `X0, V_12, V_10' have
 aditi_update_mode_errors.m:105:   the following insts:
@@ -121,8 +152,11 @@
 aditi_update_mode_errors.m:105:     free
 aditi_update_mode_errors.m:105:   which does not match any of the modes for
 aditi_update_mode_errors.m:105:   function `int.+/2'.
-aditi_update_mode_errors.m:115: In clause for `aditi_update_modes12((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:115:   in argument 2 of `aditi_bulk_modify' of predicate `aditi_update_mode_errors.p/3':
+aditi_update_mode_errors.m:115: In clause for
+aditi_update_mode_errors.m:115:   `aditi_update_modes12((aditi.aditi_di),
+aditi_update_mode_errors.m:115:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:115:   in argument 2 of `aditi_bulk_modify' of
+aditi_update_mode_errors.m:115:   predicate `aditi_update_mode_errors.p/3':
 aditi_update_mode_errors.m:115:   mode error: variable `ModifyP' has
 aditi_update_mode_errors.m:115:   instantiatedness `/* unique */(pred((free >>
 aditi_update_mode_errors.m:115:   free), (free >> ground), (free >> ground),
@@ -130,8 +164,11 @@
 aditi_update_mode_errors.m:115:   >> ground)) is semidet)',
 aditi_update_mode_errors.m:115:   expected instantiatedness was `(pred(in, out,
 aditi_update_mode_errors.m:115:   out, unused, out, out) is nondet)'.
-aditi_update_mode_errors.m:125: In clause for `aditi_update_modes13((aditi.aditi_di), (aditi.aditi_uo))':
-aditi_update_mode_errors.m:125:   in argument 2 of `aditi_bulk_modify' of function `aditi_update_mode_errors.q/2':
+aditi_update_mode_errors.m:125: In clause for
+aditi_update_mode_errors.m:125:   `aditi_update_modes13((aditi.aditi_di),
+aditi_update_mode_errors.m:125:   (aditi.aditi_uo))':
+aditi_update_mode_errors.m:125:   in argument 2 of `aditi_bulk_modify' of
+aditi_update_mode_errors.m:125:   function `aditi_update_mode_errors.q/2':
 aditi_update_mode_errors.m:125:   mode error: variable `ModifyQ' has
 aditi_update_mode_errors.m:125:   instantiatedness `/* unique */(pred((free >>
 aditi_update_mode_errors.m:125:   free), (ground >> ground), (ground >>
@@ -139,7 +176,8 @@
 aditi_update_mode_errors.m:125:   (ground >> ground)) is nondet)',
 aditi_update_mode_errors.m:125:   expected instantiatedness was `(pred(in, out,
 aditi_update_mode_errors.m:125:   out, unused, out, out) is nondet)'.
-aditi_update_mode_errors.m:047: In clause for `anc((aditi.aditi_mui), out, out)':
+aditi_update_mode_errors.m:047: In clause for `anc((aditi.aditi_mui), out,
+aditi_update_mode_errors.m:047:   out)':
 aditi_update_mode_errors.m:047:   in argument 2 of clause head:
 aditi_update_mode_errors.m:047:   mode error in unification of `X' and `X'.
 aditi_update_mode_errors.m:047:   Variable `X' has instantiatedness `free',
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.2
diff -u -b -r1.2 any_should_not_match_bound.err_exp
--- tests/invalid/any_should_not_match_bound.err_exp	18 Aug 2005 07:57:58 -0000	1.2
+++ tests/invalid/any_should_not_match_bound.err_exp	20 Aug 2005 08:16:10 -0000
@@ -1,20 +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.p/2':
+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:   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.p/2':
+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:   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.p/2':
+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:   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), out)':
-any_should_not_match_bound.m:030:   in argument 1 of call to predicate `any_should_not_match_bound.p/2':
+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:   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'.
Index: tests/invalid/bind_in_negated.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/bind_in_negated.err_exp,v
retrieving revision 1.3
diff -u -b -r1.3 bind_in_negated.err_exp
--- tests/invalid/bind_in_negated.err_exp	18 Aug 2005 07:57:58 -0000	1.3
+++ tests/invalid/bind_in_negated.err_exp	20 Aug 2005 08:16:12 -0000
@@ -1,4 +1,5 @@
-bind_in_negated.m:014: In clause for `p((bound(f(free, ground)) >> ground), (bound(f(ground, free)) >> ground), out)':
+bind_in_negated.m:014: In clause for `p((bound(f(free, ground)) >> ground),
+bind_in_negated.m:014:   (bound(f(ground, free)) >> ground), out)':
 bind_in_negated.m:014:   scope error: attempt to bind a non-local variable
 bind_in_negated.m:014:   inside the condition of an if-then-else.
 bind_in_negated.m:014:   Variable `A' has instantiatedness
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.5
diff -u -b -r1.5 bind_var_errors.err_exp
--- tests/invalid/bind_var_errors.err_exp	18 Aug 2005 07:57:58 -0000	1.5
+++ tests/invalid/bind_var_errors.err_exp	20 Aug 2005 11:46:45 -0000
@@ -9,17 +9,20 @@
 bind_var_errors.m:039:   Variable `Y' has instantiatedness `free',
 bind_var_errors.m:039:   expected instantiatedness was `unique(42)'.
 bind_var_errors.m:048: In clause for `bind_var_in_lambda':
-bind_var_errors.m:048:   in argument 1 (i.e. the predicate term) of higher-order predicate call:
+bind_var_errors.m:048:   in argument 1 (i.e. the predicate term) of
+bind_var_errors.m:048:   higher-order predicate call:
 bind_var_errors.m:048:   mode error: variable `Y' has instantiatedness `free',
 bind_var_errors.m:048:   expected instantiatedness for non-local variables of
 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.destroy/1':
+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:   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.destroy/1':
+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:   unique-mode error: the called procedure would clobber
 bind_var_errors.m:060:   its argument, but variable `X' is still live.
 For more information, try recompiling with `-E'.
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.5
diff -u -b -r1.5 constrained_poly_insts.err_exp
--- tests/invalid/constrained_poly_insts.err_exp	18 Aug 2005 07:57:58 -0000	1.5
+++ tests/invalid/constrained_poly_insts.err_exp	20 Aug 2005 08:16:22 -0000
@@ -12,7 +12,8 @@
 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:027: In clause for `t(in((I =< ground)), out((I =< ground)))':
+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.
 constrained_poly_insts.m:027:   Final instantiatedness of `HeadVar__2' was
 constrained_poly_insts.m:027:   `unique(42)',
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.4
diff -u -b -r1.4 ho_default_func_2.sub.err_exp
--- tests/invalid/ho_default_func_2.sub.err_exp	18 Aug 2005 07:57:58 -0000	1.4
+++ tests/invalid/ho_default_func_2.sub.err_exp	20 Aug 2005 08:15:54 -0000
@@ -1,5 +1,6 @@
 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.id.mkid/1':
+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:   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)',
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.3
diff -u -b -r1.3 ho_type_mode_bug.err_exp
--- tests/invalid/ho_type_mode_bug.err_exp	18 Aug 2005 07:57:58 -0000	1.3
+++ tests/invalid/ho_type_mode_bug.err_exp	20 Aug 2005 08:16:37 -0000
@@ -1,10 +1,14 @@
-ho_type_mode_bug.m:025: In clause for `my_foldl2((pred(in, in, out) is det), in, in, out, in, out)':
-ho_type_mode_bug.m:025:   in argument 1 (i.e. the predicate term) of higher-order predicate call:
+ho_type_mode_bug.m:025: In clause for `my_foldl2((pred(in, in, out) is det),
+ho_type_mode_bug.m:025:   in, in, out, in, out)':
+ho_type_mode_bug.m:025:   in argument 1 (i.e. the predicate term) of
+ho_type_mode_bug.m:025:   higher-order predicate call:
 ho_type_mode_bug.m:025:   mode error: variable `P' has instantiatedness
 ho_type_mode_bug.m:025:   `(pred(in, in, out) is det)',
 ho_type_mode_bug.m:025:   expecting higher-order pred inst (of arity 5).
-ho_type_mode_bug.m:025: In clause for `my_foldl2((pred(in, in, out) is det), in, in, out, di, uo)':
-ho_type_mode_bug.m:025:   in argument 1 (i.e. the predicate term) of higher-order predicate call:
+ho_type_mode_bug.m:025: In clause for `my_foldl2((pred(in, in, out) is det),
+ho_type_mode_bug.m:025:   in, in, out, di, uo)':
+ho_type_mode_bug.m:025:   in argument 1 (i.e. the predicate term) of
+ho_type_mode_bug.m:025:   higher-order predicate call:
 ho_type_mode_bug.m:025:   mode error: variable `P' has instantiatedness
 ho_type_mode_bug.m:025:   `(pred(in, in, out) is det)',
 ho_type_mode_bug.m:025:   expecting higher-order pred inst (of arity 5).
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.3
diff -u -b -r1.3 ho_unique_error.err_exp
--- tests/invalid/ho_unique_error.err_exp	18 Aug 2005 07:57:58 -0000	1.3
+++ tests/invalid/ho_unique_error.err_exp	20 Aug 2005 08:16:37 -0000
@@ -2,7 +2,8 @@
 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)':
-ho_unique_error.m:012:   in argument 3 (i.e. argument 2 of the called predicate) of higher-order predicate call:
+ho_unique_error.m:012:   in argument 3 (i.e. argument 2 of the called
+ho_unique_error.m:012:   predicate) of higher-order predicate call:
 ho_unique_error.m:012:   mode error: variable `DCG_0' has instantiatedness
 ho_unique_error.m:012:   `mostly_unique',
 ho_unique_error.m:012:   expected instantiatedness was `unique'.
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.9
diff -u -b -r1.9 io_in_ite_cond.err_exp
--- tests/invalid/io_in_ite_cond.err_exp	18 Aug 2005 07:57:58 -0000	1.9
+++ tests/invalid/io_in_ite_cond.err_exp	20 Aug 2005 08:16:43 -0000
@@ -1,5 +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.foo/2':
+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:   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'.
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.5
diff -u -b -r1.5 merge_ground_any.err_exp
--- tests/invalid/merge_ground_any.err_exp	18 Aug 2005 07:57:58 -0000	1.5
+++ tests/invalid/merge_ground_any.err_exp	20 Aug 2005 08:16:47 -0000
@@ -1,4 +1,6 @@
-merge_ground_any.m:013: In clause for `pass(in, in(merge_ground_any.hpair(ground, any)), out(merge_ground_any.hpair(ground, any)))':
+merge_ground_any.m:013: In clause for `pass(in,
+merge_ground_any.m:013:   in(merge_ground_any.hpair(ground, any)),
+merge_ground_any.m:013:   out(merge_ground_any.hpair(ground, any)))':
 merge_ground_any.m:013:   mode error: argument 5 did not get sufficiently
 merge_ground_any.m:013:   instantiated.
 merge_ground_any.m:013:   Final instantiatedness of `X' was
Index: tests/invalid/modes_erroneous.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/modes_erroneous.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 modes_erroneous.err_exp
--- tests/invalid/modes_erroneous.err_exp	18 Aug 2005 07:57:58 -0000	1.7
+++ tests/invalid/modes_erroneous.err_exp	20 Aug 2005 08:16:50 -0000
@@ -1,5 +1,6 @@
 modes_erroneous.m:015: In clause for `p((ground >> ground), (free >> ground))':
-modes_erroneous.m:015:   in argument 1 of call to predicate `modes_erroneous.p/2':
+modes_erroneous.m:015:   in argument 1 of call to predicate
+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/occurs.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/occurs.err_exp,v
retrieving revision 1.7
diff -u -b -r1.7 occurs.err_exp
--- tests/invalid/occurs.err_exp	25 Apr 2005 08:47:39 -0000	1.7
+++ tests/invalid/occurs.err_exp	20 Aug 2005 14:38:37 -0000
@@ -4,15 +4,13 @@
 occurs.m:008: In clause for `p':
 occurs.m:008:   mode error in unification of `X' and `occurs.f(X)'.
 occurs.m:008:   Variable `X' has instantiatedness `free',
-occurs.m:008:   term `occurs.f(X)'
-occurs.m:008:   has instantiatedness `occurs.f(
+occurs.m:008:   term `occurs.f(X)' has instantiatedness `occurs.f(
 occurs.m:008:     free
 occurs.m:008:   )'.
 occurs.m:018: In clause for `p3':
 occurs.m:018:   mode error in unification of `X' and `occurs.f(X)'.
 occurs.m:018:   Variable `X' has instantiatedness `unique(occurs.f(free))',
-occurs.m:018:   term `occurs.f(X)'
-occurs.m:018:   has instantiatedness `occurs.f(
+occurs.m:018:   term `occurs.f(X)' has instantiatedness `occurs.f(
 occurs.m:018:     unique(occurs.f(free))
 occurs.m:018:   )'.
 occurs.m:010: In `p2':
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.8
diff -u -b -r1.8 partial_implied_mode.err_exp
--- tests/invalid/partial_implied_mode.err_exp	25 Apr 2005 08:47:39 -0000	1.8
+++ tests/invalid/partial_implied_mode.err_exp	20 Aug 2005 12:15:22 -0000
@@ -1,8 +1,23 @@
-partial_implied_mode.m:033: In clause for `'__Unify__'((unique(partial_implied_mode2.physic_quantity(ground, free, unique(partial_implied_mode2.absol(free, free)))) >> bound(partial_implied_mode2.physic_quantity(ground, ground, bound(partial_implied_mode2.absol(ground, ground))))), (ground >> bound(partial_implied_mode2.physic_quantity(ground, ground, bound(partial_implied_mode2.absol(ground, ground))))))':
-partial_implied_mode.m:033:   mode error in unification of `HeadVar__1' and `partial_implied_mode2.physic_quantity(V_11, V_4, V_12)'.
-partial_implied_mode.m:033:   Variable `HeadVar__1' has instantiatedness `unique(partial_implied_mode2.physic_quantity(ground, free, unique(partial_implied_mode2.absol(free, free))))',
-partial_implied_mode.m:033:   term `partial_implied_mode2.physic_quantity(V_11, V_4, V_12)'
-partial_implied_mode.m:033:   has instantiatedness `partial_implied_mode2.physic_quantity(
+partial_implied_mode.m:033: In clause for
+partial_implied_mode.m:033:   `'__Unify__'((unique(partial_implied_mode2.physic_quantity(ground,
+partial_implied_mode.m:033:   free, unique(partial_implied_mode2.absol(free,
+partial_implied_mode.m:033:   free)))) >>
+partial_implied_mode.m:033:   bound(partial_implied_mode2.physic_quantity(ground,
+partial_implied_mode.m:033:   ground, bound(partial_implied_mode2.absol(ground,
+partial_implied_mode.m:033:   ground))))), (ground >>
+partial_implied_mode.m:033:   bound(partial_implied_mode2.physic_quantity(ground,
+partial_implied_mode.m:033:   ground, bound(partial_implied_mode2.absol(ground,
+partial_implied_mode.m:033:   ground))))))':
+partial_implied_mode.m:033:   mode error in unification of `HeadVar__1' and
+partial_implied_mode.m:033:   `partial_implied_mode2.physic_quantity(V_11, V_4,
+partial_implied_mode.m:033:   V_12)'.
+partial_implied_mode.m:033:   Variable `HeadVar__1' has instantiatedness
+partial_implied_mode.m:033:   `unique(partial_implied_mode2.physic_quantity(ground,
+partial_implied_mode.m:033:   free, unique(partial_implied_mode2.absol(free,
+partial_implied_mode.m:033:   free))))',
+partial_implied_mode.m:033:   term `partial_implied_mode2.physic_quantity(V_11,
+partial_implied_mode.m:033:   V_4, V_12)' has instantiatedness
+partial_implied_mode.m:033:   `partial_implied_mode2.physic_quantity(
 partial_implied_mode.m:033:     free,
 partial_implied_mode.m:033:     ground,
 partial_implied_mode.m:033:     free
Index: tests/invalid/polymorphic_unification.err_exp
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/invalid/polymorphic_unification.err_exp,v
retrieving revision 1.9
diff -u -b -r1.9 polymorphic_unification.err_exp
--- tests/invalid/polymorphic_unification.err_exp	18 Aug 2005 07:57:59 -0000	1.9
+++ tests/invalid/polymorphic_unification.err_exp	20 Aug 2005 08:16:59 -0000
@@ -1,4 +1,5 @@
-polymorphic_unification.m:019: In clause for `p(in, ((list.list_skel) >> dead))':
+polymorphic_unification.m:019: In clause for `p(in, ((list.list_skel) >>
+polymorphic_unification.m:019:   dead))':
 polymorphic_unification.m:019:   in polymorphically-typed unification:
 polymorphic_unification.m:019:   mode error: variable `X' has instantiatedness
 polymorphic_unification.m:019:   `bound([] ; '[|]'(free,
cvs diff: Diffing tests/invalid/purity
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.2
diff -u -b -r1.2 impure_func_t5_fixed.err_exp
--- tests/invalid/purity/impure_func_t5_fixed.err_exp	18 Aug 2005 07:58:05 -0000	1.2
+++ tests/invalid/purity/impure_func_t5_fixed.err_exp	20 Aug 2005 08:17:41 -0000
@@ -1,5 +1,6 @@
 impure_func_t5_fixed.m:022: In clause for `main(di, uo)':
-impure_func_t5_fixed.m:022:   in argument 2 (i.e. argument 1 of the called function) of impure higher-order function call:
+impure_func_t5_fixed.m:022:   in argument 2 (i.e. argument 1 of the called
+impure_func_t5_fixed.m:022:   function) of impure higher-order function call:
 impure_func_t5_fixed.m:022:   mode error: variable `V_12' has instantiatedness
 impure_func_t5_fixed.m:022:   `free',
 impure_func_t5_fixed.m:022:   expected instantiatedness was `ground'.
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.5
diff -u -b -r1.5 purity_nonsense.err_exp
--- tests/invalid/purity/purity_nonsense.err_exp	20 May 2004 22:18:40 -0000	1.5
+++ tests/invalid/purity/purity_nonsense.err_exp	21 Aug 2005 03:30:22 -0000
@@ -8,32 +8,32 @@
 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:   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 argument 1 of functor `\+/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:   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 argument 1 of functor `\+/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:   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:   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 argument 1 of functor `\+/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:   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 argument 1 of functor `\+/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':
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
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:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list