[m-rev.] for review: simplify options_file error handling
Julien Fischer
jfischer at opturion.com
Sun Jan 23 01:30:34 AEDT 2022
On Sun, 23 Jan 2022, Zoltan Somogyi wrote:
> Make options_file.m return either info or error.
>
> compiler/options_file.m:
> Change the interface of three lookup predicates to return
> either the information they are intended to look up, or a list of
> error_specs, but not both. The old code would have made sense
> if some error_specs generated during the lookup could be warnings,
> but they are always errors.
...
> diff --git a/compiler/options_file.m b/compiler/options_file.m
> index f27be9384..95643faad 100644
> --- a/compiler/options_file.m
> +++ b/compiler/options_file.m
...
> @@ -1264,29 +1261,39 @@ lookup_mercury_stdlib_dir(Variables, MaybeMerStdlibDir) :-
...
> +lookup_mmc_maybe_module_options(Variables, MaybeModuleName, Result) :-
> VariableTypes = options_variable_types,
> list.map_foldl(
> lookup_options_variable(Variables, MaybeModuleName),
> VariableTypes, VariableTypesMaybeValues, [], Specs),
> - Result = list.condense(
> - list.map(convert_to_mmc_options, VariableTypesMaybeValues)).
> + (
> + Specs = [],
> + MmcOptLists =
> + list.map(convert_to_mmc_options, VariableTypesMaybeValues),
> + list.condense(MmcOptLists, MmcOpts),
> + Result = ok1(MmcOpts)
> + ;
> + Specs = [_ | _],
> + % Returning error1 here is correct because all specs the Specs
... all spec in Specs
> + % will have severity_error. There is (as of this writing) exactly
> + % one place in this module that generates an error_spec whose
> + % severity is NOT severity_error, but it is not reachable from
> + % lookup_options_variable.
> + Result = error1(Specs)
> + ).
The rest looks fine.
Julien.
More information about the reviews
mailing list