[m-rev.] diff: --no-inform-inferred etc

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Nov 4 01:46:49 AEDT 2011


The following was contributed by Chris King.  (I have modified
the descriptions of the new options however.)

Branches main, 11.07

Add options for disabling the output generated when type and mode 
inference are enabled.

compiler/options.m:
 	Add the new options.

compiler/typecheck.m:
compiler/mode_errors.m:
 	Implement them.

doc/user_guide.texi:
 	Document the new options.

Julien.

Index: compiler/mode_errors.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_errors.m,v
retrieving revision 1.135
diff -u -r1.135 mode_errors.m
--- compiler/mode_errors.m	16 Aug 2011 03:26:32 -0000	1.135
+++ compiler/mode_errors.m	3 Nov 2011 13:50:21 -0000
@@ -1376,8 +1376,11 @@
                  FuncArgModes, RetMode, !.MaybeDet, Context)
          ),
          Pieces = [words(Verb), words(Detail), nl],
-        Msg = simple_msg(Context, [always(Pieces)]),
-        Spec = error_spec(severity_informational,
+        Msg = simple_msg(Context,
+            [option_is_set(inform_inferred_modes, yes, [always(Pieces)])]),
+        Severity = severity_conditional(inform_inferred_modes, yes,
+            severity_informational, no),
+        Spec = error_spec(Severity,
              phase_mode_check(report_in_any_mode), [Msg])
      ).

Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.706
diff -u -r1.706 options.m
--- compiler/options.m	3 Nov 2011 10:13:39 -0000	1.706
+++ compiler/options.m	3 Nov 2011 14:14:05 -0000
@@ -138,6 +138,9 @@
      ;       warn_unresolved_polymorphism
      ;       warn_suspicious_foreign_procs
      ;       warn_state_var_shadowing
+    ;       inform_inferred
+    ;       inform_inferred_types
+    ;       inform_inferred_modes

      % Verbosity options
      ;       verbose
@@ -1113,7 +1116,10 @@
      inform_ite_instead_of_switch        -   bool(no),
      warn_unresolved_polymorphism        -   bool(yes),
      warn_suspicious_foreign_procs       -   bool(no),
-    warn_state_var_shadowing            -   bool(yes)
+    warn_state_var_shadowing            -   bool(yes),
+    inform_inferred                     -   bool_special,
+    inform_inferred_types               -   bool(yes),
+    inform_inferred_modes               -   bool(yes)
  ]).
  option_defaults_2(verbosity_option, [
      % Verbosity Options
@@ -1972,6 +1978,9 @@
  long_option("warn-unresolved-polymorphism", warn_unresolved_polymorphism).
  long_option("warn-suspicious-foreign-procs", warn_suspicious_foreign_procs).
  long_option("warn-state-var-shadowing", warn_state_var_shadowing).
+long_option("inform-inferred",          inform_inferred).
+long_option("inform-inferred-types",    inform_inferred_types).
+long_option("inform-inferred-modes",    inform_inferred_modes).

  % verbosity options
  long_option("verbose",                  verbose).
@@ -3072,6 +3081,13 @@
          host_env_type, string(EnvTypeStr)),
          target_env_type, string(EnvTypeStr)).

+special_handler(inform_inferred, bool(Inform), !.OptionTable,
+        ok(!:OptionTable)) :-
+    override_options([
+            inform_inferred_types -   bool(Inform),
+            inform_inferred_modes -   bool(Inform)
+        ], !OptionTable).
+
  %-----------------------------------------------------------------------------%

  option_table_add_mercury_library_directory(OptionTable0, Dir) =
@@ -3544,7 +3560,13 @@
          "\tWarn about possible errors in the bodies of foreign",
          "\tprocedures.",
          "--no-warn-state-var-shadowing",
-        "\tDo not warn about one state variable shadowing another."
+        "\tDo not warn about one state variable shadowing another.",
+        "--no-inform-inferred",
+        "\tDo not generate messages about inferred types or modes.",
+        "--no-inform-inferred-types",
+        "\tDo not generate messages about inferred types.",
+        "--no-inform-inferred-modes",
+        "\tDo not generate messages about inferred modes."
      ]).

  :- pred options_help_verbosity(io::di, io::uo) is det.
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.464
diff -u -r1.464 typecheck.m
--- compiler/typecheck.m	19 Oct 2011 01:08:30 -0000	1.464
+++ compiler/typecheck.m	3 Nov 2011 13:50:21 -0000
@@ -318,8 +318,11 @@
              AppendVarNums)
      ),
      Pieces = [words("Inferred"), words(TypeStr), nl],
-    Msg = simple_msg(Context, [always(Pieces)]),
-    Spec = error_spec(severity_informational, phase_type_check, [Msg]).
+    Msg = simple_msg(Context,
+        [option_is_set(inform_inferred_types, yes, [always(Pieces)])]),
+    Severity = severity_conditional(inform_inferred_types, yes,
+        severity_informational, no),
+    Spec = error_spec(Severity, phase_type_check, [Msg]).

  :- func typecheck_report_max_iterations_exceeded(int) = error_spec.

Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.640
diff -u -r1.640 user_guide.texi
--- doc/user_guide.texi	24 Oct 2011 14:09:22 -0000	1.640
+++ doc/user_guide.texi	3 Nov 2011 14:38:54 -0000
@@ -6579,6 +6579,21 @@
  @item --no-warn-state-var-shadowing
  @findex --no-warn-state-var-shadowing
  Do not warn about one state variable shadowing another.
+
+ at sp 1
+ at item --no-inform-inferred
+ at findex --no-inform-inferred
+Do not generate messages about inferred types or modes.
+
+ at sp 1
+ at item --no-inform-inferred-types
+ at findex --no-inform-inferred-types
+Do not generate messages about inferred types.
+
+ at sp 1
+ at item --no-inform-inferred-modes
+ at findex --no-inform-inferred-modes
+Do not generate messages about inferred modes.
  @end table

  @node Verbosity options
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list