When you get this message, the error may be in the module name that it
reports to be wrong, but it may be in the places that set the compiler's
expectations of what the name of the module should be. This latter is
very likely the case when one moves a module of the Mercury compiler
from one package to another. In such cases, the problems are the old modules
that continue to refer to the renamed module by its old name.
This diff includes in the error message the identities of the modules
that refer to the old name; these are the modules that establish the
expectation that is not met.
compiler/deps_map.m:
When tracing references from module A to module B.C (either because
A imports B.C, or because A = B and A includes C), record A as a source
of the expectation that any file that contains module C will have
B.C as module C's fully qualified name. Since a module is usually imported
by more than one other module, there may be several sources of such
expectations.
compiler/parse_module.m:
Require callers of the functions that read in modules from files
to specify the contexts of the places that establish the expectation
of the module's fully qualified name.
When the expectation is not met, include the contexts in the error message.
compiler/read_modules.m:
Pass those contexts through to parse_module.m.
compiler/find_module.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/modules.m:
compiler/recompilation.check.m:
Conform to the changes above.
tests/invalid/bad_module_name.err_exp:
Expect the updated error message.
compiler/file_names.m:
Change the order of arguments of module_name_to_file_name and related
predicates to make it easier to construct closures from them. Delete
the previous higher-order-friendly versions, which the previous step
has made unnecessary.
compiler/compile_target_code.m:
compiler/elds_to_erlang.m:
compiler/export.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/intermod.m:
compiler/llds_out_file.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/mmc_analysis.m:
compiler/mode_constraints.m:
compiler/module_cmds.m:
compiler/modules.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/write_deps_file.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
Conform to the change above. In several places, this means replacing
explicit lambda expressions with simple partial application of the
relevant predicates.
compiler/analysis.file.m:
compiler/make.module_dep_file.m:
compiler/parse_module.m:
compiler/recompilation.check.m:
When calling the parser, explicitly specify the stream to read
the term from; don't touch the current input stream.
compiler/find_module.m:
Pass the stream to read from explicitly to parse_module.m.
compiler/file_util.m:
The predicates in this module that find the file containing a Mercury
module used to allow the caller to specify that if the file can be
successfully opened, then the current input stream should be set to
the resulting stream. This meant that callers had to save the original
current input stream *before* calling this predicate, and later restore it,
*without* anything in between that would signal to readers of the code
that the current input stream had ever been changed.
Replace each of these predicates with two predicates. One returns
the stream as an explicit part of an output argument, letting the caller
do with the stream what it wished (in some cases, that would mean
using it in I/O operations as *explicitly* passed parameters, which
would not require touching the identity of the current input stream),
giving it the responsibility to close the stream when it is done using it.
The other would close the stream immediately, not letting the caller know
that the file was ever opened. The two versions are distinguised both
by name and by return type.
compiler/find_module.m:
Make the same change to search_for_module_source. (This predicate was
the motivation for this change, because unlike the predicates in
file_util.m, its signature did NOT provide readers with any sort of clue
that the searched-for file would actually be opened, and that the
resulting stream would become the new current input stream.)
Clarify the code that tries to find the source file for a module
by dropping qualifiers from the module name by (a) giving the predicate
a more explicit name, and (b) separating the search from the code
that handles the failure of the search.
compiler/parse_module.m:
compiler/read_modules.m:
Change part of the interface between these two modules. This used to be
that code in read_modules.m passed closures to parse_module.m for it
to invoke, closures whose predicates were always one of the predicates
affected by the changes above. Simplify the interface by making
read_modules.m invoke those predicates directly, and simply pass
the results.
compiler/compile_target_code.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/mercury_compile_front_end.m:
compiler/mmc_analysis.m:
compiler/module_cmds.m:
compiler/options_file.m:
compiler/write_deps_file.m:
Conform to the changes above.