compiler/write_module_interface_files.m:
When the process of generating the contents of an interface file
finds some errors, don't print those errors immediately. Just return
them instead, letting the caller decide what to do with them.
Fix comment rot.
compiler/make.get_module_dep_info.m:
compiler/mercury_compile_main.m:
Print the error specs returned by the updated predicates (for now,
at least).
compiler/error_sort.m:
Fix an issue exposed by the changes above. When comparing two error_specs
to see which one should be printed first, don't take the lack of a content
in an error_spec as a sign that it should be printed first. Instead,
pay attention to the comparison of contexts *only* if both of the
error_specs being compared actually *have* contexts.
tests/invalid/type_inf_loop.err_exp:
Expect the contextless message about exceeding the type inference
iteration limit to come after the other messages, due to the update
to error_sort.m.
tests/invalid/type_inf_loop.err_exp2:
Delete this file. It can't match the compiler's current output,
or (it seems) the output of any compiler version since we switched
to reporting type errors using error_specs.
compiler/mercury_compile_main.m:
The handle_given_options predicate, besides computing the direct effect
of a given list of command line arguments on the option table, also
- looks for and reports inconsistencies between option values,
- applies implications between options, and
- constructs the global structure.
The code in the initial part of mercury_compile_main.m has long had
calls to handle_given_options that did not really need any of this work
to be done. The calls were nevertheless there because the later code,
even though it needed unly the updated option table, could only
*use* that updated option table if it was part of a globals structure.
This diff makes a start on fixing that. It replaces two calls
to handle_given_options with calls to getopt.process_options_userdata_io,
which just returns the updated option table. It updates the code following
those two calls to use the updated option table directly, NOT through
a globals structure. The rest of this diff is there to make this possible.
compiler/check_libgrades.m:
Make maybe_detect_stdlib_grades take an option_table, not a globals
structure.
compiler/write_error_spec.m:
Provide a version of write_error_specs that takes an option_table,
not a globals structure.
The changes in the following modules are there to implement this change.
compiler/compiler_util.m:
Provide a version of record_warning that takes an option_table,
not a globals structure.
compiler/error_sort.m:
Provide a version of sort_error_specs that takes an option_table,
not a globals structure.
compiler/error_spec.m:
Provide a version of extract_spec_msgs that takes an option_table,
not a globals structure.
compiler/error_util.m:
Do the same for several functions dealing with severities.
compiler/error_spec.m:
This new module contains the part of the old error_util.m that defines
the error_spec type, and some functions that can help construct pieces
of error_specs. Most modules of the compiler that deal with errors
will need to import only this part of the old error_util.m.
This change also renames the format_component type to format_piece,
which matches our long-standing naming convention for variables containing
(lists of) values of this type.
compiler/write_error_spec.m:
This new module contains the part of the old error_util.m that
writes out error specs, and converts them to strings.
This diff marks as obsolete the versions of predicates that
write out error specs to the current output stream, without
*explicitly* specifying the intended stream.
compiler/error_sort.m:
This new module contains the part of the old error_util.m that
sorts lists of error specs and error msgs.
compiler/error_type_util.m:
This new module contains the part of the old error_util.m that
convert types to format_pieces that generate readable output.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/error_util.m:
The code remaining in the original error_util.m consists of
general utility predicates and functions that don't fit into
any of the modules above.
Delete an unneeded pair of I/O states from the argument list
of a predicate.
compiler/file_util.m:
Move the unable_to_open_file predicate here from error_util.m,
since it belongs here. Mark another predicate that writes
to the current output stream as obsolete.
compiler/hlds_error_util.m:
Mark two predicates that wrote out error_spec to the current output
stream as obsolete, and add versions that take an explicit output stream.
compiler/Mercury.options:
Compile the modules that call the newly obsoleted predicates
with --no-warn-obsolete, for the time being.
compiler/*.m:
Conform to the changes above, mostly by updating import_module
declarations, and renaming format_component to format_piece.