tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the tests
that check compiler error messages, expect the new line numbers.
browser/cterm.m:
browser/tree234_cc.m:
Import only one module per line.
tests/hard_coded/boyer.m:
Fix something I missed.
Estimated hours taken: 28
Branches: main
A big step towards cleaning up the way we handle errors. The main changes are
- the provision, in error_util.m, of a mechanism for completely specifying
everything to do with a single error in one data structure,
- the conversion of typecheck_errors.m from using io.write_string to
using this new capability,
- the conversion of mode_errors.m and det_report.m from using
write_error_pieces to using this new capability, and
- consistently using the quoting style `symname'/N instead of `symname/N'
in error_util and hlds_error_util (previously, error_util used the former
but hlds_error_util used the latter).
This diff sets up later diffs which will collect all error specifications
in a central place and print them all at once, in order.
compiler/error_util.m:
The new type error_spec, which completely specifies an error.
An error_spec may have multiple components with different contexts
and may have parts which are printed only under certain conditions,
e.g. a given option being set. Each error_spec has a severity
and also records which phase found the error.
The new predicate write_error_spec takes care of updates of the exit
status for errors and (if --halt-at-warn is set) for warnings. It also
takes care of setting the flag that calls for the reminder about -E
at the end.
This diff also makes it simpler to use the ability to print arbitrary
output. It adds the ability to include integers in messages directly,
and the ability to create blank lines. It renames some function symbols
to avoid ambiguities.
Move a predicate that only used by typecheck_errors.m to that file.
compiler/hlds_error_util.m:
Switch to the `symname'/N quoting style for describing predicates and
procedures.
compiler/prog_util.m:
Switch to the `symname'/N quoting style for describing
sym_name_and_arity.
compiler/hlds_module.m:
Provide a predicate to increment the number of errors not by one,
but by the number of errors printed by write_error_spec.
Fix some documentation rot.
compiler/typecheck_errors.m:
Use write_error_spec instead of io.write_strings to print error
messages. In several cases, improve the formatting of the messages
printed.
Mark a number of places where we don't (yet) update the number of
errors in the module_info correctly.
Rename the checkpoint predicate to avoid potential ambiguity with
similar predicates in e.g. mode_info.
compiler/typecheck_info.m:
Group the code for writing stuff out together in one bunch. For each
such predicate, create another that returns a list of format components
instead of doing I/O directly.
compiler/typecheck.m:
Move the code for writing inference messages here from
typecheck_errors.m, since these messages aren't errors.
compiler/mode_errors.m:
compiler/det_report.m:
Use write_error_spec instead of write_error_pieces. In the case of
mode_errors.m, this means we now get correct the set of circumstances
in which we set the flag that calls for the reminder about -E.
compiler/add_pragma.m:
compiler/add_type.m:
Convert some code that used to use write_error_pieces to print error
messages to use write_error_spec instead.
compiler/assertion.m:
compiler/hlds_pred.m:
compiler/post_typecheck.m:
Assertion.m used to contain some code to check for assertions in the
interface that mention predicates that are not exported. Move most
of this code to post_typecheck.m (which is where this code used to be
called from). One small part, which is a test for a particular property
of import_statuses, is moved to hlds_pred.m to be with all the other
similar tests of import_statuses.
compiler/prog_util.m:
Change unqualify_name from a predicate to a function.
compiler/pred_table.m:
compiler/hlds_out.m:
Avoid some ambiguities by adding a suffix to the names of some
predicates.
compiler/*.m:
Conform to the changes above.
library/list.m:
Add a function that was previously present (with different names)
in two compiler modules.
tests/hard_coded/allow_stubs.exp:
Update the format of the expected exception.
tests/invalid/errors2.err_exp2:
Remove this file. As far as I can tell, it was never the correct
expected output on the main branch. (It originated on the alias branch
way back in the mists of time.)
tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/warnings/*.exp:
Update the format of the expected error messages.
tests/recompilation/*.err_exp.2:
Update the format of the expected messages about what was modified.
Estimated hours taken: 16
Branches: main
Give the compiler the capability of detecting errors that manifest themselves
as mismatches between the format string and the list of values to be printed
in calls to string.format and io.format.
This capability is controlled through two new options:
--warn-known-bad-format-calls
--warn-unknown-format-calls
The first (which will default to "on" once this change has bootstrapped)
controls whether the compiler emits warnings for statically known mismatches.
The second (which will default to "off") controls whether the compiler emits
warnings in cases where either the format string or the structure of the list
of values to be printed is not available statically to be checked.
NEWS:
Mention the new capability.
compiler/options.m:
Add the two new options.
doc/user_guide.texi:
Document the new options.
compiler/format_call.m:
New module to implement the new capability.
compiler/notes/compiler_structure.html:
Document the new module.
compiler/check_hlds.m:
Include the new module.
compiler/simplify.m:
Invoke the new module if the procedure being processed contains calls
to string.format or io.format.
Fix an old bug: we could generate warnings or even errors when
simplifying predicate bodies imported from other modules via
intermodule optimization.
Don't export get/set predicates that do not need to be exported.
compiler/det_report.m:
Add new kinds of error specifications for the errors detected by the
new module.
Separate out the context of each error specification, in order
to allow the error messages to be sorted by context; this makes
the output much easier to read.
compiler/common.m:
compiler/det_analysis.m:
compiler/simplify.m:
Conform to the change to det_report.m.
mdbcomp/prim_data.m:
Add a utility function for forming the possibly qualified names of
library modules (such as "io" and "string").
library/Mercury.options:
compiler/Mercury.options:
Add the lines that disable the new checks in the modules that need them
disabled. The new lines are commented out until installed compilers all
understand them, at which point in time we will add the requirement to
understand the option to configure.in.
compiler/fact_table.m:
compiler/mlds_to_il.m:
Fix three bugs reported by the new check that have apparently escaped
detection all this time.
library/rtti_implementation.m:
Change some code to avoid a spurious warning from the new checks.
library/string.m:
Rename a predicate to avoid an unnecessary and confusing overloading of
its name.
Replace __ with . as module qualifier connective.
compiler/handle_options.m:
library/pprint.m:
Misc cleanups.
tests/invalid/string_format_bad.{m,err_exp}:
tests/invalid/string_format_unknown.{m,err_exp}:
New test cases to test the new warnings.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
Enable the new test cases.
tests/general/string_format_test*.exp*:
Update any expected abort messages to expect . instead of __ as module
qualifier connective.
tests/invalid/det_errors_cc.err_exp:
tests/invalid/erroneous_throw_promise.err_exp:
tests/warnings/simple_code.exp:
Expect the same error messages in program context order.
Estimated hours taken: 8
Branches: main
Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.
The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.
compiler/det_analysis.m:
Keep track of goals to the right of the current goal that could fail,
and include them in the error representation if required.
compiler/det_report.m:
Include the list of failing goals to the right in the representations
of determinism errors involving committed committed choice goals.
Convert the last part of this module that wasn't using error_util
to use error_util. Make most parts of this module just construct
error message specifications; print those specifications (using
error_util) in only a few places.
compiler/hlds_out.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
Add a function for use by the new code in det_report.m.
compiler/error_util.m:
compiler/compiler_util.m:
Error_util is still changing reasonably often, and yet it is
included in lots of modules, most of which need only a few simple
non-parse-tree-related predicates from it (e.g. unexpected).
Move those predicates to a new module, compiler_util.m. This also
eliminates some undesirable dependencies from libs to parse_tree.
compiler/libs.m:
Include compiler_util.m.
compiler/notes/compiler_design.html:
Document compiler_util.m, and fix the documentation of some other
modules.
compiler/*.m:
Import compiler_util instead of or in addition to error_util.
To make this easier, consistently use . instead of __ for module
qualifying module names.
tests/invalid/det_errors_cc.{m,err_exp}:
Add this new test case to test the error messages for cc contexts.
tests/invalid/det_errors_deet.{m,err_exp}:
Add this new test case to test the error messages for unifications
inside function symbols.
tests/invalid/Mmakefile:
Add the new test cases.
tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
Change the expected output to conform to the change in det_report.m,
which is now more consistent.