The failure was caused by an error message generated by prog_io.m about a
problem (a file containing the wrong module) being ignored by deps_map.m.
A different problem was that we detected and generated error messages for this
problem in several places, which had different expectations and had access
to different information, and (partially but not wholly as a result of that)
generated different text. This diff makes all the pieces of code that detect
this problem use the same code to generate an error message. (Having only
one place to *detect* the problem would be more trouble that it is worth;
it would replace a few simple pieces of code with one larger, more complex
piece of code that would still have to cover all the relevant use cases,
but now removed from the rest of the code handling those use cases as well.)
It would probably be a good idea to unify those use cases as much as possible,
but that would be a much more complex change.
compiler/prog_io.m.m:
Generalize the predicate that generates error messages for wrong module
names, check_module_has_expected_name, to make it usable from both
prog_io.m and read_modules.m.
Replace a piece of code that had the same job with a call to this
predicate.
compiler/read_modules.m.m:
When reading in source files, ignore the errors that arise from
trying to read nonexistent files if our caller asks us to do so
(since some callers are not sure about what file a module is stored in),
but if the file *is* found and opened, then do *not* ignore the
errors we generate in parsing its contents.
Call the generalized version of check_module_has_expected_name,
and pass it the info it needs (the context of the module declaration).
compiler/deps_map.m:
If the read-in module contains a different module name than expected,
we already generated an error message for it, which read_modules.m
now doesn't throw away, so we now just keep that message,
and don't generate a redundant one.
compiler/error_util.m:
When sorting error messages, we have, for a long time now, deleted
duplicates. However, two error messages can differ in one having
conditional inclusion of format components and the other always
including the same components. We don't want to get two copies
of the error message if the condition is true, so we now evaluate
the conditions before sorting the messages. This is needed because
the code in prog_io.m that generates error messages for wrong module names
has to work in different conditions that have different ideas of how
bad an error a wrong module name is.
Provide a mechanism (a new phase in error messages) to separate
error messages about wrong module names from other errors.
This was part of an earlier attempt at solving the same problem
using a different approach (generating a new error message about
the problem only if we haven't already generated a message about it),
but that approach had the problem that the text of the generated message
could differ if it was generated in more than place, making it hard
to write a good test case. (Hence the generalization of
check_module_has_expected_name: although in some situations it generates
unconditional and in other condition error messages, the text in those
messages is always the same.) However, the new phase doesn't hurt
anything, and may be useful later, e.g. to handle modules like
tests/invalid_purity/purity_nonsense2.m differently, so keep it.
tests/invalid/Mmakefile:
Execute the purity_nonsense2 test case without first generating its
dependencies. If we did generate its dependencies, then due to the
fact that we no longer ignore errors during that step, we would
get *only* those errors, and not also the ones discovered by parts
of the compiler invoked later, and which are also expected by
purity_nonsense2.err_exp.
tests/invalid/bad_module_name.err_exp:
Expect the updated text of the "wrong module name" error message.
tests/invalid/missing_interface_import2.{m,err_exp}:
Due to a missing :- interface declaration, this test case wasn't testing
what it was testing. Add the missing section marker, and expect the updated
line numbers.
tools/bootcheck:
Print an explicit message at the end of a successful bootchecks.
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.
Branches: main
Delete some deprecated modules from the standard library.
library/graph.m:
library/group.m:
Delete the contents of these files.
library/library.m:
Do not include the above modules in the library.
tests/invalid/missing_interface_import3.m:
tests/invalid/missing_interface_import2.{m,err_exp}:
Replace a use of the group module in this test.
NEWS:
Announce the above, plus the recent removal of the relation
module.
Estimated hours taken: 100
Branches: main
Make definitions of abstract types available when generating
code for importing modules. This is necessary for the .NET
back-end, and for `:- pragma export' on the C back-end.
compiler/prog_data.m:
compiler/modules.m:
compiler/make.dependencies.m:
compiler/recompilation.version.m:
Handle implementation sections in interface files.
There is a new pseudo-declaration `abstract_imported'
which is applied to items from the implementation
section of an interface file. `abstract_imported'
items may not be used in the error checking passes
for the curent module.
compiler/equiv_type_hlds.m:
compiler/notes/compiler_design.html:
New file.
Go over the HLDS expanding all types fully after
semantic checking has been run.
compiler/mercury_compile.m:
Add the new pass.
Don't write the `.opt' file if there are any errors.
compiler/instmap.m:
Add a predicate instmap_delta_map_foldl to apply
a procedure to all insts in an instmap.
compiler/equiv_type.m:
Export predicates for use by equiv_type_hlds.m
Reorder arguments so state variables and higher-order
programming can be used.
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
compiler/mercury_to_mercury.m:
Handle `:- pragma foreign_type' as a form of type
declaration rather than a pragma.
compiler/hlds_data.m:
compiler/*.m:
Add a field to the type_info_cell_constructor cons_id
to identify the type_ctor, which is needed by
equiv_type_hlds.m.
compiler/module_qual.m:
Donn't allow items from the implementation section of
interface files to match items in the current module.
compiler/*.m:
tests/*/*.m:
Add missing imports which only became apparent with
the bug fixes above.
Remove unnecessary imports which only became apparent with
the bug fixes above.
tests/hard_coded/Mmakefile:
tests/hard_coded/export_test2.{m,exp}:
Test case.
tests/invalid/Mmakefile:
tests/invalid/missing_interface_import2.{m,err_exp}:
Test case.