[m-rev.] trivial diff: fix the formatting of an error message
Julien Fischer
juliensf at cs.mu.OZ.AU
Wed Jun 14 17:35:41 AEST 2006
Estimated hours taken: 0.5
Branches: main, release
Fix a badly formatted verbose error message.
compiler/det_report.m:
Fix the formatting of the error message.
Fix a typo: s/appropiate/appropriate/
Replace an if-then-else with switch.
compiler/accumulator.m:
compiler/mode_errors.m:
compiler/prog_io_util.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/typecheck_errors.m:
Minor formatting fixes.
Fix some spelling errors.
tests/invalid/Mercury.options:
tests/invalid/multisoln_func.err_exp:
Test the verbose error message for this test case.
Julien.
Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.57
diff -u -r1.57 accumulator.m
--- compiler/accumulator.m 31 Mar 2006 03:32:09 -0000 1.57
+++ compiler/accumulator.m 14 Jun 2006 06:35:42 -0000
@@ -5,12 +5,12 @@
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
-
+%
% Module: accumulator.m.
% Main authors: petdr.
-
+%
% Attempts to transform a single proc to a tail recursive form by
-% introducing accumlators. The algorithm can do this if the code after
+% introducing accumulators. The algorithm can do this if the code after
% the recursive call has either the order independent state update or
% associative property.
%
@@ -136,10 +136,10 @@
% transformation attempts to move each recursive call to the end
% until one succeeds. This makes the order of independent recursive
% calls in the body irrelevant.
-
+%
% XXX replace calls to can_reorder_goals with calls to the version that
% use the intermodule-analysis framework.
-
+%
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -196,6 +196,7 @@
%-----------------------------------------------------------------------------%
% The form of the goal around the base and recursive cases.
+ %
:- type top_level
---> switch_base_rec
; switch_rec_base
@@ -208,12 +209,15 @@
% stores which conjunction the goal came from (base or
% recursive), and the second stores the location of the goal in
% the conjunction.
+ %
:- type goal_id == pair(int).
% The goal_store associates a goal with each goal_id.
+ %
:- type goal_store == goal_store(goal_id).
- % A substition from the first variable name to the second.
+ % A substitution from the first variable name to the second.
+ %
:- type subst == map(prog_var, prog_var).
:- type warning
@@ -553,7 +557,7 @@
% store(Id, G, SI0, SI) is true iff the goal G is stored inside
% the goal_store (which is part of SI) with the correct
- % identifier and instmap associatied with the goal.
+ % identifier and instmap associated with the goal.
%
:- pred store(int::in, hlds_goal::in, store_info::in, store_info::out) is det.
@@ -1246,7 +1250,7 @@
%-----------------------------------------------------------------------------%
- % For each member of the update set determine the substitions
+ % For each member of the update set determine the substitutions
% needed (creating the accumulator variables when needed).
% Also associate with each Output variable which accumulator
% variable to get the result from.
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.119
diff -u -r1.119 det_report.m
--- compiler/det_report.m 8 Jun 2006 08:19:10 -0000 1.119
+++ compiler/det_report.m 14 Jun 2006 06:25:05 -0000
@@ -5,14 +5,15 @@
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
-
+%
% File: det_report.m.
% Author: zs.
-
+%
% This module handles reporting of determinism errors and warnings,
% as well as errors and warnings from some other related compiler passes
% such as simplify.
-
+%
+%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- module check_hlds.det_report.
@@ -256,7 +257,7 @@
\+ is_unify_or_compare_pred(PredInfo0),
% Don't warn about predicates which are inferred erroneous
- % when the appropiate option is set. This is to avoid warnings
+ % when the appropriate option is set. This is to avoid warnings
% about unimplemented predicates.
(
WarnAboutInferredErroneous = yes
@@ -409,9 +410,8 @@
globals.io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
(
VerboseErrors = yes,
- ExtMsg = func_primary_mode_det_msg,
write_error_pieces_not_first_line(FuncContext, 0,
- [words(ExtMsg)], !IO)
+ func_primary_mode_det_msg, !IO)
;
VerboseErrors = no,
globals.io_set_extra_error_info(yes, !IO)
@@ -421,20 +421,22 @@
true
).
-:- func func_primary_mode_det_msg = string.
+:- func func_primary_mode_det_msg = format_components.
-func_primary_mode_det_msg =
- "In Mercury, a function is supposed to be a true mathematical" ++
- "function of its arguments; that is, the value of the function's" ++
- "result should be determined only by the values of its arguments." ++
- "(Allowing functions to have more than one result for the same" ++
- "arguments would break referential transparency.)" ++
- "Most likely, this procedure should be a predicate, not a function.".
+func_primary_mode_det_msg = [
+ words("In Mercury, a function is supposed to be a true mathematical"),
+ words("function of its arguments; that is, the value of the function's"),
+ words("result should be determined only by the values of its arguments."),
+ words("(Allowing functions to have more than one result for the same"),
+ words("arguments would break referential transparency.)"),
+ words("Most likely, this procedure should be a predicate, not a function.")
+ ].
det_check_lambda(DeclaredDetism, InferredDetism, Goal, GoalInfo, DetInfo,
Msgs) :-
compare_determinisms(DeclaredDetism, InferredDetism, Cmp),
- ( Cmp = tighter ->
+ (
+ Cmp = tighter,
det_info_get_pred_id(DetInfo, PredId),
det_info_get_proc_id(DetInfo, ProcId),
goal_info_get_context(GoalInfo, Context),
@@ -443,6 +445,9 @@
ContextMsg = context_det_msg(Context, Msg),
Msgs = [ContextMsg]
;
+ ( Cmp = sameas
+ ; Cmp = looser
+ ),
% We don't bother issuing warnings if the determinism was too loose;
% that will often be the case, and should not be warned about.
Msgs = []
Index: compiler/mode_errors.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.101
diff -u -r1.101 mode_errors.m
--- compiler/mode_errors.m 20 Apr 2006 05:36:56 -0000 1.101
+++ compiler/mode_errors.m 14 Jun 2006 06:21:17 -0000
@@ -5,12 +5,12 @@
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
-
+%
% File: mode_errors.m.
% Main author: fjh.
-
+%
% This module contains all the error-reporting routines for the mode-checker.
-
+%
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -53,7 +53,7 @@
; mode_error_par_conj(merge_errors)
% Different arms of a parallel conj result in mutually exclusive
- % bindings - ie the process of unifying the instmaps from the end
+ % bindings - i.e. the process of unifying the instmaps from the end
% of each branch failed.
; mode_error_higher_order_pred_var(pred_or_func, prog_var, mer_inst,
Index: compiler/prog_io_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/prog_io_util.m,v
retrieving revision 1.46
diff -u -r1.46 prog_io_util.m
--- compiler/prog_io_util.m 29 Mar 2006 08:07:18 -0000 1.46
+++ compiler/prog_io_util.m 14 Jun 2006 06:36:11 -0000
@@ -20,6 +20,9 @@
% which will either be the `ok(ParseTree)' (or `ok(ParseTree1, ParseTree2)'),
% if the parse is successful, or `error(Message, Term)' if it is not.
% The `Term' there should be the term which is syntactically incorrect.
+%
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- module parse_tree.prog_io_util.
:- interface.
Index: compiler/term_constr_errors.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/term_constr_errors.m,v
retrieving revision 1.4
diff -u -r1.4 term_constr_errors.m
--- compiler/term_constr_errors.m 29 Mar 2006 08:07:24 -0000 1.4
+++ compiler/term_constr_errors.m 14 Jun 2006 06:29:14 -0000
@@ -5,10 +5,11 @@
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
-
+%
% File: term_constr_errors.m.
% Main author: juliensf.
-
+%
+%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- module transform_hlds.term_constr_errors.
@@ -33,34 +34,30 @@
% unconstrained.
:- type termination2_error
- ---> imported_pred
- % Termination could not be proved because
- % it depends upon information from another
- % module and that information is not
- % available.
+ ---> imported_pred
+ % Termination could not be proved because it depends upon
+ % information from another module and that information is not
+ % available.
; can_loop_proc_called(pred_proc_id, pred_proc_id)
- % Termination could not be proved because
- % the procedure called another procedure
- % that may not terminate.
+ % Termination could not be proved because the procedure called
+ % another procedure that may not terminate.
; cond_not_satisfied
- % Termination could not be proved because
- % no set of decreasing argument could be found.
+ % Termination could not be proved because no set of decreasing
+ % argument could be found.
; horder_call
- % Termination could not be proved because
- % the procedure makes higher-order calls.
+ % Termination could not be proved because the procedure makes
+ % higher-order calls.
; does_not_term_pragma(pred_id)
- % Termination could not be proved because
- % the procedure was marked with a
- % `does_not_terminate' pragma.
+ % Termination could not be proved because the procedure was marked
+ % with a `does_not_terminate' pragma.
; foreign_proc_called(pred_proc_id).
- % Termination depends upon the properties
- % of a piece of foreign code that cannot
- % be established as terminating.
+ % Termination depends upon the properties of a piece of foreign
+ % code that cannot be established as terminating.
:- type term_constr_errors.error == pair(prog_context, termination2_error).
@@ -90,13 +87,13 @@
%-----------------------------------------------------------------------------%
-report_termination2_errors(SCC, Errors, !Module, !IO) :-
+report_termination2_errors(SCC, Errors, !ModuleInfo, !IO) :-
globals.io_lookup_bool_option(check_termination2, NormalErrors, !IO),
globals.io_lookup_bool_option(verbose_check_termination2,
VerboseErrors, !IO),
(
IsCheckTerm = (pred(PPId::in) is semidet :-
- module_info_pred_proc_info(!.Module, PPId, PredInfo, _),
+ module_info_pred_proc_info(!.ModuleInfo, PPId, PredInfo, _),
not pred_info_is_imported(PredInfo),
pred_info_get_markers(PredInfo, Markers),
check_marker(Markers, check_termination)
@@ -104,12 +101,12 @@
CheckTermPPIds = list.filter(IsCheckTerm, SCC),
list.is_not_empty(CheckTermPPIds)
->
- report_term_errors(SCC, Errors, !.Module, !IO),
+ report_term_errors(SCC, Errors, !.ModuleInfo, !IO),
io.set_exit_status(1, !IO),
- module_info_incr_errors(!Module)
+ module_info_incr_errors(!ModuleInfo)
;
IsNonImported = (pred(PPId::in) is semidet :-
- module_info_pred_proc_info(!.Module, PPId, PredInfo, _),
+ module_info_pred_proc_info(!.ModuleInfo, PPId, PredInfo, _),
not pred_info_is_imported(PredInfo)
),
NonImportedPPIds = list.filter(IsNonImported, SCC),
@@ -123,19 +120,21 @@
),
PrintErrors0 = list.filter(IsNonSimple, Errors),
%
- % If there are no direct errors report
- % the indirect ones instead.
+ % If there are no direct errors report the indirect ones instead.
%
- ( if PrintErrors0 = []
- then PrintErrors = Errors
- else PrintErrors = PrintErrors0
+ (
+ PrintErrors0 = [],
+ PrintErrors = Errors
+ ;
+ PrintErrors0 = [_ | _],
+ PrintErrors = PrintErrors0
)
;
fail
)
->
- term_constr_errors.report_term_errors(SCC, PrintErrors,
- !.Module, !IO)
+ term_constr_errors.report_term_errors(SCC, PrintErrors, !.ModuleInfo,
+ !IO)
;
true
).
Index: compiler/term_errors.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/term_errors.m,v
retrieving revision 1.38
diff -u -r1.38 term_errors.m
--- compiler/term_errors.m 29 Mar 2006 08:07:25 -0000 1.38
+++ compiler/term_errors.m 14 Jun 2006 06:21:45 -0000
@@ -5,13 +5,14 @@
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
-
+%
% File: term_errors.m.
% Main author: crs.
-
+%
% This module prints out the various error messages that are produced by the
% various modules of termination analysis.
-
+%
+%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
:- module transform_hlds.term_errors.
Index: compiler/typecheck_errors.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck_errors.m,v
retrieving revision 1.21
diff -u -r1.21 typecheck_errors.m
--- compiler/typecheck_errors.m 6 Jun 2006 03:25:59 -0000 1.21
+++ compiler/typecheck_errors.m 14 Jun 2006 06:24:25 -0000
@@ -13,6 +13,7 @@
% typechecking.
%
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- module check_hlds.typecheck_errors.
:- interface.
@@ -1211,7 +1212,7 @@
"\tThe way to add an explicit type qualification is to use ""with_type"".\n",
"\tFor details see the ""Explicit type qualification"" sub-section\n",
"\tof the ""Data-terms"" section of the ""Syntax"" chapter\n",
-"\tof the Mercury langauge reference manual.\n"
+"\tof the Mercury language reference manual.\n"
], !IO)
;
true
Index: tests/invalid/Mercury.options
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/Mercury.options,v
retrieving revision 1.13
diff -u -r1.13 Mercury.options
--- tests/invalid/Mercury.options 27 Jan 2006 05:52:23 -0000 1.13
+++ tests/invalid/Mercury.options 14 Jun 2006 07:24:13 -0000
@@ -60,7 +60,7 @@
--no-automatic-intermodule-optimization
MCFLAGS-mode_inf = --infer-all
MCFLAGS-mpj1 = --infer-all
-MCFLAGS-multisoln_func = --infer-types
+MCFLAGS-multisoln_func = --infer-types --verbose-error-messages
MCFLAGS-no_exports = --halt-at-warn
MCFLAGS-nonexistent_import = --no-verbose-make --make nonexistent_import
MCFLAGS-overloading = --no-intermodule-optimization \
Index: tests/invalid/multisoln_func.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/multisoln_func.err_exp,v
retrieving revision 1.6
diff -u -r1.6 multisoln_func.err_exp
--- tests/invalid/multisoln_func.err_exp 14 Sep 2005 05:26:49 -0000 1.6
+++ tests/invalid/multisoln_func.err_exp 14 Jun 2006 07:25:58 -0000
@@ -3,11 +3,51 @@
multisoln_func.m:034: Inferred :- func test3b(int) = int.
multisoln_func.m:013: Error: invalid determinism for `f(in) = out':
multisoln_func.m:013: the primary mode of a function cannot be `cc_multi'.
+multisoln_func.m:013: In Mercury, a function is supposed to be a true
+multisoln_func.m:013: mathematical function of its arguments; that is, the
+multisoln_func.m:013: value of the function's result should be determined
+multisoln_func.m:013: only by the values of its arguments. (Allowing
+multisoln_func.m:013: functions to have more than one result for the same
+multisoln_func.m:013: arguments would break referential transparency.) Most
+multisoln_func.m:013: likely, this procedure should be a predicate, not a
+multisoln_func.m:013: function.
multisoln_func.m:019: Error: invalid determinism for `test = out':
multisoln_func.m:019: the primary mode of a function cannot be `cc_multi'.
+multisoln_func.m:019: In Mercury, a function is supposed to be a true
+multisoln_func.m:019: mathematical function of its arguments; that is, the
+multisoln_func.m:019: value of the function's result should be determined
+multisoln_func.m:019: only by the values of its arguments. (Allowing
+multisoln_func.m:019: functions to have more than one result for the same
+multisoln_func.m:019: arguments would break referential transparency.) Most
+multisoln_func.m:019: likely, this procedure should be a predicate, not a
+multisoln_func.m:019: function.
multisoln_func.m:026: Error: invalid determinism for `test2 = out':
multisoln_func.m:026: the primary mode of a function cannot be `multi'.
+multisoln_func.m:026: In Mercury, a function is supposed to be a true
+multisoln_func.m:026: mathematical function of its arguments; that is, the
+multisoln_func.m:026: value of the function's result should be determined
+multisoln_func.m:026: only by the values of its arguments. (Allowing
+multisoln_func.m:026: functions to have more than one result for the same
+multisoln_func.m:026: arguments would break referential transparency.) Most
+multisoln_func.m:026: likely, this procedure should be a predicate, not a
+multisoln_func.m:026: function.
multisoln_func.m:030: Error: invalid determinism for `test3(in) = out':
multisoln_func.m:030: the primary mode of a function cannot be `nondet'.
+multisoln_func.m:030: In Mercury, a function is supposed to be a true
+multisoln_func.m:030: mathematical function of its arguments; that is, the
+multisoln_func.m:030: value of the function's result should be determined
+multisoln_func.m:030: only by the values of its arguments. (Allowing
+multisoln_func.m:030: functions to have more than one result for the same
+multisoln_func.m:030: arguments would break referential transparency.) Most
+multisoln_func.m:030: likely, this procedure should be a predicate, not a
+multisoln_func.m:030: function.
multisoln_func.m:034: Error: invalid determinism for `test3b(in) = out':
multisoln_func.m:034: the primary mode of a function cannot be `cc_nondet'.
+multisoln_func.m:034: In Mercury, a function is supposed to be a true
+multisoln_func.m:034: mathematical function of its arguments; that is, the
+multisoln_func.m:034: value of the function's result should be determined
+multisoln_func.m:034: only by the values of its arguments. (Allowing
+multisoln_func.m:034: functions to have more than one result for the same
+multisoln_func.m:034: arguments would break referential transparency.) Most
+multisoln_func.m:034: likely, this procedure should be a predicate, not a
+multisoln_func.m:034: function.
--------------------------------------------------------------------------
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