Skip to content

Commit 64e801c

Browse files
committed
Setting an unknown option now always a warning. Fixes rocq-prover#4947.
Previously, setting an unknown option was an error or a warning, depending on the type of the option. We make it always a warning, for forward compatibility. This was already fixed in 8.6.
1 parent 513e194 commit 64e801c

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

library/goptions.ml

+14-16
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,18 @@ let declare_stringopt_option =
304304
(* Setting values of options *)
305305

306306
let set_option_value locality check_and_cast key v =
307-
let (name, depr, (_,read,write,lwrite,gwrite)) =
308-
try get_option key
309-
with Not_found ->
310-
errorlabstrm "Goptions.set_option_value"
311-
(str "There is no option " ++ str (nickname key) ++ str ".")
312-
in
313-
let write = match locality with
314-
| None -> write
315-
| Some true -> lwrite
316-
| Some false -> gwrite
317-
in
318-
write (check_and_cast v (read ()))
307+
let opt = try Some (get_option key) with Not_found -> None in
308+
match opt with
309+
| None ->
310+
msg_warning
311+
(str "There is no option " ++ str (nickname key) ++ str ".")
312+
| Some (name, depr, (_,read,write,lwrite,gwrite)) ->
313+
let write = match locality with
314+
| None -> write
315+
| Some true -> lwrite
316+
| Some false -> gwrite
317+
in
318+
write (check_and_cast v (read ()))
319319

320320
let bad_type_error () = error "Bad type of value for this option."
321321

@@ -345,13 +345,11 @@ let check_unset_value v = function
345345
let set_int_option_value_gen locality =
346346
set_option_value locality check_int_value
347347
let set_bool_option_value_gen locality key v =
348-
try set_option_value locality check_bool_value key v
349-
with UserError (_,s) -> msg_warning s
348+
set_option_value locality check_bool_value key v
350349
let set_string_option_value_gen locality =
351350
set_option_value locality check_string_value
352351
let unset_option_value_gen locality key =
353-
try set_option_value locality check_unset_value key ()
354-
with UserError (_,s) -> msg_warning s
352+
set_option_value locality check_unset_value key ()
355353

356354
let set_int_option_value = set_int_option_value_gen None
357355
let set_bool_option_value = set_bool_option_value_gen None

0 commit comments

Comments
 (0)