[m-rev.] for review: handle_given_options should not set exit status

Peter Wang novalazy at gmail.com
Wed Jul 11 12:32:47 AEST 2012


Branches: main, 11.07

handle_given_options should not set the exist status.

The first time that real_main_after_expansion calls handle_given_options,
errors due to incompatible options should be tolerated because not all the
options are known yet.  But handle_given_options already set the exit status.

This prevented normal use of the --warn-non-tail-recursion option:
--mlds-optimize is initially set to `no', which implies --no-optimize-tailcalls,
which is incompatible with --warn-non-tail-recursion.

compiler/handle_options.m:
	As above.

diff --git a/compiler/handle_options.m b/compiler/handle_options.m
index 29f0b23..b02039c 100644
--- a/compiler/handle_options.m
+++ b/compiler/handle_options.m
@@ -36,6 +36,8 @@
     % handle_given_options(Args, OptionArgs, NonOptionArgs, Link,
     %   Errors, Globals, !IO).
     %
+    % This predicate does NOT modify the exit status.
+    %
 :- pred handle_given_options(list(string)::in,
     list(string)::out, list(string)::out, bool::out, list(string)::out,
     globals::out, io::di, io::uo) is det.
@@ -117,8 +119,9 @@ handle_given_options(Args0, OptionArgs, Args, Link, Errors, !:Globals, !IO) :-
     convert_option_table_result_to_globals(Result, Errors, !:Globals, !IO),
     (
         Errors = [_ | _],
-        Link = no,
-        io.set_exit_status(1, !IO)
+        Link = no
+        % Do NOT set the exit status.  This predicate may be called before all
+        % the options are known, so the errors may not be valid.
     ;
         Errors = [],
         globals.lookup_bool_option(!.Globals, generate_dependencies,

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