diff --git a/browser/browser_info.m b/browser/browser_info.m index bef6db2e5..d507aedb5 100644 --- a/browser/browser_info.m +++ b/browser/browser_info.m @@ -342,8 +342,6 @@ :- implementation. -:- import_module mdb.term_rep. - :- import_module deconstruct. :- import_module require. :- import_module string. diff --git a/browser/declarative_analyser.m b/browser/declarative_analyser.m index b7f154665..e092715c4 100644 --- a/browser/declarative_analyser.m +++ b/browser/declarative_analyser.m @@ -143,7 +143,6 @@ :- implementation. :- import_module mdb.browser_info. -:- import_module mdb.declarative_edt. :- import_module mdb.declarative_execution. :- import_module mdbcomp.prim_data. :- import_module mdbcomp.program_representation. diff --git a/browser/declarative_tree.m b/browser/declarative_tree.m index 638e630fa..a1eeb53fd 100644 --- a/browser/declarative_tree.m +++ b/browser/declarative_tree.m @@ -58,7 +58,6 @@ :- import_module mdb.term_rep. :- import_module mdbcomp.goal_path. :- import_module mdbcomp.prim_data. -:- import_module mdbcomp.program_representation. :- import_module mdbcomp.rtti_access. :- import_module mdbcomp.sym_name. diff --git a/browser/frame.m b/browser/frame.m index 2d69764ea..da425ad9e 100644 --- a/browser/frame.m +++ b/browser/frame.m @@ -68,7 +68,6 @@ :- import_module assoc_list. :- import_module int. -:- import_module list. :- import_module string. %---------------------------------------------------------------------------% diff --git a/browser/name_mangle.m b/browser/name_mangle.m index e15a3333d..fc54f9b4b 100644 --- a/browser/name_mangle.m +++ b/browser/name_mangle.m @@ -69,7 +69,6 @@ :- implementation. :- import_module char. -:- import_module int. :- import_module list. :- import_module string. diff --git a/browser/util.m b/browser/util.m index ff9ea9e43..1202a0888 100644 --- a/browser/util.m +++ b/browser/util.m @@ -55,7 +55,6 @@ :- implementation. :- import_module require. -:- import_module string. %---------------------------------------------------------------------------% diff --git a/compiler/Mercury.options b/compiler/Mercury.options index 98f29524a..1c3e2c2a1 100644 --- a/compiler/Mercury.options +++ b/compiler/Mercury.options @@ -20,6 +20,26 @@ MCFLAGS-hlds.quantification = --optimize-unused-args # in the common case that the trace goals are not enabled. MCFLAGS-check_hlds.typecheck = --unneeded-code +# In these files, some imports are needed only in some grades. +# Until unused_imports.m can avoid generating messages about these, +# disable the pass on these files. +MCFLAGS-libs.md4 = --no-warn-unused-imports +MCFLAGS-libs.process_util = --no-warn-unused-imports +MCFLAGS-libs.timestamp = --no-warn-unused-imports + +# In these packages, some imports are needed only by some submodules. +MCFLAGS-erl_backend = --no-warn-unused-imports +MCFLAGS-hlds = --no-warn-unused-imports +MCFLAGS-ll_backend = --no-warn-unused-imports +MCFLAGS-make = --no-warn-unused-imports +MCFLAGS-ml_backend = --no-warn-unused-imports +MCFLAGS-parse_tree = --no-warn-unused-imports +MCFLAGS-recompilation = --no-warn-unused-imports +MCFLAGS-top_level = --no-warn-unused-imports +MCFLAGS-transform_hlds = --no-warn-unused-imports +MCFLAGS-transform_hlds.ctgc.structure_reuse = --no-warn-unused-imports +MCFLAGS-transform_hlds.ctgc.structure_sharing = --no-warn-unused-imports + # process_util.m uses `kill' and `struct sigaction' from , # which are not available with `--ansi'. MGNUCFLAGS-libs.process_util = --no-ansi @@ -36,24 +56,12 @@ MGNUCFLAGS-make.program_target = --no-ansi MCFLAGS-check_hlds.modes = --inline-vars-threshold 10000 MCFLAGS-check_hlds.unique_modes = --inline-vars-threshold 10000 -MCFLAGS-libs.process_util = --no-ansi-c +MCFLAGS-libs.process_util += --no-ansi-c MCFLAGS-make.module_dep_file = --no-ansi-c MCFLAGS-make.module_target = --no-ansi-c MCFLAGS-make.program_target = --no-ansi-c MCFLAGS-make.util = --no-ansi-c -MCFLAGS-erl_backend = --no-warn-unused-imports -MCFLAGS-hlds = --no-warn-unused-imports -MCFLAGS-ll_backend = --no-warn-unused-imports -MCFLAGS-make = --no-warn-unused-imports -MCFLAGS-ml_backend = --no-warn-unused-imports -MCFLAGS-parse_tree = --no-warn-unused-imports -MCFLAGS-recompilation = --no-warn-unused-imports -MCFLAGS-top_level = --no-warn-unused-imports -MCFLAGS-transform_hlds = --no-warn-unused-imports -MCFLAGS-transform_hlds.ctgc.structure_reuse = --no-warn-unused-imports -MCFLAGS-transform_hlds.ctgc.structure_sharing = --no-warn-unused-imports - # These modules provide general-purpose wrappers around string.format # in which the format strings are known only by their callers. MCFLAGS-transform_hlds.pd_debug = --no-warn-unknown-format-calls diff --git a/compiler/add_class.m b/compiler/add_class.m index da9b74e5d..d2e16603a 100644 --- a/compiler/add_class.m +++ b/compiler/add_class.m @@ -73,7 +73,6 @@ :- import_module require. :- import_module set. :- import_module solutions. -:- import_module string. :- import_module varset. module_add_class_defn(ItemTypeClassInfo, Status, !ModuleInfo, !Specs) :- diff --git a/compiler/add_clause.m b/compiler/add_clause.m index f7cc0a6cc..d1b8e86b4 100644 --- a/compiler/add_clause.m +++ b/compiler/add_clause.m @@ -51,11 +51,9 @@ :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_goal. :- import_module hlds.hlds_out.hlds_out_util. -:- import_module hlds.hlds_pred. :- import_module hlds.hlds_rtti. :- import_module hlds.make_goal. :- import_module hlds.make_hlds.add_pred. -:- import_module hlds.make_hlds.field_access. :- import_module hlds.make_hlds.goal_expr_to_goal. :- import_module hlds.make_hlds.make_hlds_warn. :- import_module hlds.make_hlds.state_var. @@ -65,21 +63,17 @@ :- import_module libs.options. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.module_qual. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_io_util. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_out. :- import_module parse_tree.prog_util. :- import_module parse_tree.prog_rename. -:- import_module assoc_list. :- import_module bool. :- import_module int. :- import_module io. :- import_module map. -:- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module varset. diff --git a/compiler/add_foreign_proc.m b/compiler/add_foreign_proc.m index 1d4c6af90..3c7530b78 100644 --- a/compiler/add_foreign_proc.m +++ b/compiler/add_foreign_proc.m @@ -53,6 +53,7 @@ :- import_module parse_tree.prog_util. :- import_module assoc_list. +:- import_module bool. :- import_module bag. :- import_module cord. :- import_module int. diff --git a/compiler/add_heap_ops.m b/compiler/add_heap_ops.m index c81d5cef9..0511fbdaf 100644 --- a/compiler/add_heap_ops.m +++ b/compiler/add_heap_ops.m @@ -52,7 +52,6 @@ :- import_module hlds.vartypes. :- import_module mdbcomp.builtin_modules. :- import_module mdbcomp.prim_data. -:- import_module mdbcomp.sym_name. :- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.prog_data. diff --git a/compiler/add_mutable_aux_preds.m b/compiler/add_mutable_aux_preds.m index e900e8ef8..fbbc20c73 100644 --- a/compiler/add_mutable_aux_preds.m +++ b/compiler/add_mutable_aux_preds.m @@ -48,7 +48,6 @@ :- import_module hlds.hlds_out.hlds_out_mode. :- import_module hlds.make_hlds.add_clause. :- import_module hlds.make_hlds.add_foreign_proc. -:- import_module hlds.make_hlds.add_pragma. :- import_module libs. :- import_module libs.globals. :- import_module libs.options. @@ -59,12 +58,11 @@ :- import_module parse_tree.prog_foreign. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_mutable. -:- import_module parse_tree.prog_util. -:- import_module varset. -:- import_module pair. +:- import_module bool. :- import_module require. :- import_module string. +:- import_module varset. %---------------------------------------------------------------------------% diff --git a/compiler/add_pragma.m b/compiler/add_pragma.m index 9abff0693..131e721f4 100644 --- a/compiler/add_pragma.m +++ b/compiler/add_pragma.m @@ -45,8 +45,6 @@ :- import_module hlds.make_hlds.add_pragma.add_pragma_type_spec. :- import_module hlds.make_hlds.add_pred. :- import_module hlds.make_hlds.make_hlds_error. -:- import_module hlds.make_hlds.make_hlds_warn. -:- import_module hlds.make_hlds.qual_info. :- import_module hlds.make_tags. :- import_module hlds.pred_table. :- import_module libs.globals. @@ -61,15 +59,12 @@ :- import_module transform_hlds.term_constr_util. :- import_module transform_hlds.term_util. -:- import_module assoc_list. :- import_module bool. :- import_module int. :- import_module io. -:- import_module list. :- import_module map. :- import_module require. :- import_module set. -:- import_module string. :- import_module varset. %-----------------------------------------------------------------------------% diff --git a/compiler/add_pred.m b/compiler/add_pred.m index c0391b6c7..ccfe33b11 100644 --- a/compiler/add_pred.m +++ b/compiler/add_pred.m @@ -78,7 +78,6 @@ :- import_module hlds.hlds_args. :- import_module hlds.hlds_data. :- import_module hlds.hlds_goal. -:- import_module hlds.hlds_pred. :- import_module hlds.hlds_rtti. :- import_module hlds.make_hlds.make_hlds_error. :- import_module hlds.pred_table. @@ -93,8 +92,8 @@ :- import_module parse_tree.prog_util. :- import_module parse_tree.set_of_var. +:- import_module bool. :- import_module map. -:- import_module set. :- import_module require. :- import_module term. :- import_module varset. diff --git a/compiler/add_solver.m b/compiler/add_solver.m index f0fa86abb..54c5663fc 100644 --- a/compiler/add_solver.m +++ b/compiler/add_solver.m @@ -58,13 +58,11 @@ :- implementation. :- import_module hlds.make_hlds.add_foreign_proc. -:- import_module hlds.make_hlds.add_pragma. % ZZZ :- import_module hlds.make_hlds.add_pred. :- import_module libs.globals. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_type. -:- import_module bool. :- import_module map. :- import_module require. :- import_module string. diff --git a/compiler/add_type.m b/compiler/add_type.m index 5c81a10e5..2dbdbc4b7 100644 --- a/compiler/add_type.m +++ b/compiler/add_type.m @@ -70,7 +70,6 @@ :- import_module int. :- import_module map. :- import_module multi_map. -:- import_module pair. :- import_module require. :- import_module string. :- import_module term. diff --git a/compiler/analysis.file.m b/compiler/analysis.file.m index 210365676..2350ec0a8 100644 --- a/compiler/analysis.file.m +++ b/compiler/analysis.file.m @@ -103,7 +103,6 @@ :- implementation. -:- import_module libs.globals. :- import_module libs.options. :- import_module libs.pickle. :- import_module parse_tree. @@ -117,6 +116,7 @@ :- import_module exception. :- import_module parser. :- import_module require. +:- import_module string. :- import_module term. :- import_module term_io. :- import_module type_desc. diff --git a/compiler/analysis.m b/compiler/analysis.m index d4c9a43b3..1962073de 100644 --- a/compiler/analysis.m +++ b/compiler/analysis.m @@ -14,7 +14,7 @@ % Nicholas Nethercote. The Analysis Framework of HAL, % Chapter 7: Inter-module Analysis, Master's Thesis, % University of Melbourne, September 2001, revised April 2002. -% . +% . % %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -74,7 +74,7 @@ ) => analysis(FuncInfo, Call, Answer). % An analysis is defined by a type describing call patterns and - % a type defining answer patterns. If the analysis needs to store + % a type defining answer patterns. If the analysis needs to store % more information about the function being analysed (e.g. arity) % it should be stored as part of the type for call patterns. % @@ -271,10 +271,10 @@ % LocalModuleNames, !Info, !IO) % % This predicate should be called before any pass begins to use the - % analysis framework. It ensures that all the analysis files - % are loaded so that lookups can be satisfied. ImportedModuleNames is the + % analysis framework. It ensures that all the analysis files + % are loaded so that lookups can be satisfied. ImportedModuleNames is the % set of all modules that are directly or indirectly imported by the - % module being analysed. LocalModuleNames is the set of non-"library" + % module being analysed. LocalModuleNames is the set of non-"library" % modules. % :- pred prepare_intermodule_analysis(globals::in, set(module_name)::in, @@ -319,13 +319,11 @@ :- include_module analysis.file. :- import_module analysis.file. -:- import_module libs. :- import_module parse_tree. % XXX unwanted dependency :- import_module parse_tree.module_cmds. % XXX unwanted dependency :- import_module map. :- import_module require. -:- import_module string. :- import_module type_desc. :- import_module univ. diff --git a/compiler/arg_info.m b/compiler/arg_info.m index f4636a8ec..625331723 100644 --- a/compiler/arg_info.m +++ b/compiler/arg_info.m @@ -138,7 +138,6 @@ :- implementation. :- import_module check_hlds.mode_util. -:- import_module hlds.hlds_pred. :- import_module libs.globals. :- import_module libs.options. :- import_module parse_tree.builtin_lib_types. diff --git a/compiler/base_typeclass_info.m b/compiler/base_typeclass_info.m index ab883ba88..ae63aee8e 100644 --- a/compiler/base_typeclass_info.m +++ b/compiler/base_typeclass_info.m @@ -47,22 +47,16 @@ :- import_module hlds.hlds_data. :- import_module hlds.hlds_pred. :- import_module hlds.hlds_rtti. -:- import_module mdbcomp. -:- import_module mdbcomp.prim_data. :- import_module parse_tree. :- import_module parse_tree.prog_data. -:- import_module parse_tree.prog_type. :- import_module parse_tree.status. :- import_module assoc_list. :- import_module bool. -:- import_module int. :- import_module map. :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module string. -:- import_module term. %---------------------------------------------------------------------------% diff --git a/compiler/builtin_lib_types.m b/compiler/builtin_lib_types.m index 003e7c29f..1b47a67e3 100644 --- a/compiler/builtin_lib_types.m +++ b/compiler/builtin_lib_types.m @@ -106,7 +106,6 @@ :- import_module mdbcomp.sym_name. :- import_module list. -:- import_module map. %-----------------------------------------------------------------------------% diff --git a/compiler/bytecode_gen.m b/compiler/bytecode_gen.m index 2ce7f34d6..e56a4d9e7 100644 --- a/compiler/bytecode_gen.m +++ b/compiler/bytecode_gen.m @@ -74,12 +74,9 @@ :- import_module counter. :- import_module deconstruct. :- import_module int. -:- import_module list. :- import_module map. :- import_module pair. :- import_module require. -:- import_module set. -:- import_module set_tree234. :- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/c_util.m b/compiler/c_util.m index f4046f120..f815d0e29 100644 --- a/compiler/c_util.m +++ b/compiler/c_util.m @@ -197,12 +197,10 @@ :- implementation. -:- import_module libs.compiler_util. :- import_module libs.options. :- import_module bool. :- import_module int. -:- import_module list. :- import_module require. :- import_module string. diff --git a/compiler/call_gen.m b/compiler/call_gen.m index 68cbefdef..198d77cdb 100644 --- a/compiler/call_gen.m +++ b/compiler/call_gen.m @@ -84,7 +84,6 @@ :- import_module bool. :- import_module cord. :- import_module int. -:- import_module map. :- import_module maybe. :- import_module pair. :- import_module require. diff --git a/compiler/check_typeclass.m b/compiler/check_typeclass.m index 57806a640..bf9d5df86 100644 --- a/compiler/check_typeclass.m +++ b/compiler/check_typeclass.m @@ -138,7 +138,6 @@ :- import_module pair. :- import_module require. :- import_module set. -:- import_module set_tree234. :- import_module solutions. :- import_module string. :- import_module term. @@ -604,7 +603,7 @@ check_class_instance(ClassId, SuperClasses, Vars, HLDSClassInterface, :- pred check_concrete_class_instance(class_id::in, list(tvar)::in, hlds_class_interface::in, class_interface::in, list(pred_id)::in, term.context::in, - instance_methods::in, hlds_instance_defn::in, hlds_instance_defn::out, + list(instance_method)::in, hlds_instance_defn::in, hlds_instance_defn::out, module_info::in, module_info::out, make_hlds_qual_info::in, make_hlds_qual_info::out, list(error_spec)::in, list(error_spec)::out) is det. @@ -661,7 +660,7 @@ check_concrete_class_instance(ClassId, Vars, HLDSClassInterface, % any of the methods from the class interface. If so, add an appropriate % error message to the list of error messages. % -:- pred check_for_bogus_methods(instance_methods::in, class_id::in, +:- pred check_for_bogus_methods(list(instance_method)::in, class_id::in, list(pred_id)::in, prog_context::in, module_info::in, list(error_spec)::in, list(error_spec)::out) is det. @@ -698,9 +697,11 @@ check_for_bogus_methods(InstanceMethods, ClassId, ClassPredIds, Context, :- type instance_check_info ---> instance_check_info( hlds_instance_defn, - instance_methods, % The instance methods in reverse - % order of the methods in the class - % declaration. + + % The instance methods in reverse order of the methods + % in the class declaration. + list(instance_method), + module_info, make_hlds_qual_info ). @@ -825,7 +826,7 @@ check_instance_pred(ClassId, ClassVars, ClassInterface, PredId, :- pred check_instance_pred_procs(class_id::in, list(tvar)::in, sym_name::in, pred_markers::in, hlds_instance_defn::in, hlds_instance_defn::out, - instance_methods::in, instance_methods::out, + list(instance_method)::in, list(instance_method)::out, instance_method_info::in, instance_method_info::out, list(error_spec)::in, list(error_spec)::out) is det. @@ -881,7 +882,7 @@ check_instance_pred_procs(ClassId, ClassVars, MethodName, Markers, % being combined into a single definition. % :- pred get_matching_instance_defns(instance_body::in, pred_or_func::in, - sym_name::in, arity::in, instance_methods::out) is det. + sym_name::in, arity::in, list(instance_method)::out) is det. get_matching_instance_defns(instance_body_abstract, _, _, _, []). get_matching_instance_defns(instance_body_concrete(InstanceMethods), @@ -2103,7 +2104,7 @@ collect_determined_vars(FunDep @ fundep(Domain, Range), !FunDeps, !Vars) :- % Duplicate method definition error. % :- pred report_duplicate_method_defn(class_id::in, hlds_instance_defn::in, - pred_or_func::in, sym_name::in, arity::in, instance_methods::in, + pred_or_func::in, sym_name::in, arity::in, list(instance_method)::in, list(error_spec)::in, list(error_spec)::out) is det. report_duplicate_method_defn(ClassId, InstanceDefn, PredOrFunc, MethodName, @@ -2173,7 +2174,7 @@ report_undefined_method(ClassId, InstanceDefn, PredOrFunc, MethodName, Arity, %---------------------------------------------------------------------------% -:- pred report_bogus_instance_methods(class_id::in, instance_methods::in, +:- pred report_bogus_instance_methods(class_id::in, list(instance_method)::in, prog_context::in, list(error_spec)::in, list(error_spec)::out) is det. report_bogus_instance_methods(ClassId, BogusInstanceMethods, Context, diff --git a/compiler/code_info.m b/compiler/code_info.m index 653c5126a..6078d8dca 100644 --- a/compiler/code_info.m +++ b/compiler/code_info.m @@ -62,7 +62,6 @@ :- import_module libs.options. :- import_module libs.trace_params. :- import_module ll_backend.code_util. -:- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.prog_type. :- import_module cord. diff --git a/compiler/common.m b/compiler/common.m index 26dc67c89..8969f6c6d 100644 --- a/compiler/common.m +++ b/compiler/common.m @@ -177,10 +177,8 @@ :- import_module bool. :- import_module eqvclass. :- import_module map. -:- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module term. %---------------------------------------------------------------------------% diff --git a/compiler/comp_unit_interface.m b/compiler/comp_unit_interface.m index 07ee253a0..243d14564 100644 --- a/compiler/comp_unit_interface.m +++ b/compiler/comp_unit_interface.m @@ -79,7 +79,6 @@ :- import_module parse_tree.item_util. :- import_module parse_tree.status. -:- import_module bool. :- import_module cord. :- import_module maybe. :- import_module set. diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m index c618a49c9..b2aea1eeb 100644 --- a/compiler/compile_target_code.m +++ b/compiler/compile_target_code.m @@ -245,13 +245,11 @@ :- implementation. -:- import_module libs.globals. :- import_module libs.handle_options. :- import_module libs.options. :- import_module libs.trace_params. :- import_module parse_tree.error_util. :- import_module parse_tree.file_names. -:- import_module parse_tree.java_names. :- import_module parse_tree.module_cmds. :- import_module parse_tree.write_deps_file. :- import_module parse_tree.prog_foreign. diff --git a/compiler/complexity.m b/compiler/complexity.m index 8509109a1..a3f5a6714 100644 --- a/compiler/complexity.m +++ b/compiler/complexity.m @@ -86,7 +86,6 @@ :- import_module list. :- import_module map. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/const_prop.m b/compiler/const_prop.m index a775bb87a..e588212b8 100644 --- a/compiler/const_prop.m +++ b/compiler/const_prop.m @@ -47,18 +47,13 @@ :- implementation. -:- import_module hlds.hlds_goal. :- import_module hlds.make_goal. -:- import_module hlds.instmap. -:- import_module libs.globals. :- import_module libs.int_emu. :- import_module libs.options. -:- import_module parse_tree.prog_data. :- import_module bool. :- import_module float. :- import_module int. -:- import_module list. :- import_module map. :- import_module maybe. :- import_module pair. diff --git a/compiler/continuation_info.m b/compiler/continuation_info.m index 3c566ccf2..07fb648a0 100644 --- a/compiler/continuation_info.m +++ b/compiler/continuation_info.m @@ -407,9 +407,7 @@ :- implementation. -:- import_module check_hlds.inst_match. :- import_module check_hlds.type_util. -:- import_module hlds.hlds_goal. :- import_module hlds.hlds_llds. :- import_module libs.options. :- import_module ll_backend.code_util. @@ -418,7 +416,6 @@ :- import_module int. :- import_module require. -:- import_module solutions. :- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/coverage_profiling.m b/compiler/coverage_profiling.m index 80a0b6c24..226b055de 100644 --- a/compiler/coverage_profiling.m +++ b/compiler/coverage_profiling.m @@ -60,7 +60,6 @@ :- import_module map. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. % Information used by the coverage profiling transformation. diff --git a/compiler/cse_detection.m b/compiler/cse_detection.m index 20e668c3a..2468452f4 100644 --- a/compiler/cse_detection.m +++ b/compiler/cse_detection.m @@ -72,7 +72,6 @@ :- import_module check_hlds.inst_match. :- import_module check_hlds.modes. :- import_module check_hlds.switch_detection. -:- import_module check_hlds.switch_detection. :- import_module check_hlds.type_util. :- import_module hlds.hlds_goal. :- import_module hlds.hlds_out. @@ -89,7 +88,6 @@ :- import_module parse_tree. :- import_module parse_tree.error_util. :- import_module parse_tree.prog_data. -:- import_module parse_tree.prog_type_subst. :- import_module parse_tree.set_of_var. :- import_module assoc_list. diff --git a/compiler/ctgc.datastruct.m b/compiler/ctgc.datastruct.m index 9413144a3..a29f6b18b 100644 --- a/compiler/ctgc.datastruct.m +++ b/compiler/ctgc.datastruct.m @@ -94,8 +94,6 @@ :- import_module hlds.vartypes. :- import_module transform_hlds.ctgc.selector. -:- import_module map. - %-----------------------------------------------------------------------------% datastruct_init(V) = datastruct_init_with_selector(V, []). diff --git a/compiler/ctgc.fixpoint_table.m b/compiler/ctgc.fixpoint_table.m index c70c457d3..6d2b72e40 100644 --- a/compiler/ctgc.fixpoint_table.m +++ b/compiler/ctgc.fixpoint_table.m @@ -90,7 +90,6 @@ :- implementation. :- import_module int. -:- import_module list. :- import_module map. :- import_module require. diff --git a/compiler/ctgc.livedata.m b/compiler/ctgc.livedata.m index 0240a598c..89c2631ff 100644 --- a/compiler/ctgc.livedata.m +++ b/compiler/ctgc.livedata.m @@ -89,11 +89,9 @@ :- import_module parse_tree.set_of_var. :- import_module transform_hlds.ctgc.datastruct. -:- import_module transform_hlds.ctgc.structure_sharing.domain. :- import_module pair. :- import_module require. -:- import_module set. %-----------------------------------------------------------------------------% diff --git a/compiler/ctgc.selector.m b/compiler/ctgc.selector.m index b70a30e24..45e1c9968 100644 --- a/compiler/ctgc.selector.m +++ b/compiler/ctgc.selector.m @@ -98,7 +98,6 @@ :- import_module require. :- import_module set. :- import_module solutions. -:- import_module string. %-----------------------------------------------------------------------------% diff --git a/compiler/ctgc.util.m b/compiler/ctgc.util.m index af6de6437..631296ed2 100644 --- a/compiler/ctgc.util.m +++ b/compiler/ctgc.util.m @@ -81,7 +81,6 @@ :- import_module parse_tree.status. :- import_module bool. -:- import_module list. :- import_module map. :- import_module require. diff --git a/compiler/dead_proc_elim.m b/compiler/dead_proc_elim.m index 4b40fedc9..842f471aa 100644 --- a/compiler/dead_proc_elim.m +++ b/compiler/dead_proc_elim.m @@ -91,7 +91,6 @@ :- import_module libs.globals. :- import_module libs.options. :- import_module mdbcomp.builtin_modules. -:- import_module parse_tree.error_util. :- import_module parse_tree.prog_data. :- import_module parse_tree.status. diff --git a/compiler/deforest.m b/compiler/deforest.m index f674ec5e3..bc2666955 100644 --- a/compiler/deforest.m +++ b/compiler/deforest.m @@ -54,7 +54,6 @@ :- import_module check_hlds.mode_util. :- import_module check_hlds.modecheck_util. :- import_module check_hlds.simplify. -:- import_module check_hlds.simplify.simplify_proc. :- import_module check_hlds.simplify.simplify_tasks. :- import_module hlds.goal_form. :- import_module hlds.goal_util. diff --git a/compiler/delay_info.m b/compiler/delay_info.m index f2203cf1b..6ccf5597c 100644 --- a/compiler/delay_info.m +++ b/compiler/delay_info.m @@ -96,7 +96,6 @@ :- implementation. -:- import_module check_hlds.mode_errors. :- import_module parse_tree.set_of_var. :- import_module cord. diff --git a/compiler/delay_partial_inst.m b/compiler/delay_partial_inst.m index 0b4d9759b..65e2f0f55 100644 --- a/compiler/delay_partial_inst.m +++ b/compiler/delay_partial_inst.m @@ -144,7 +144,6 @@ :- import_module bool. :- import_module io. :- import_module map. -:- import_module maybe. :- import_module pair. :- import_module require. :- import_module string. diff --git a/compiler/dense_switch.m b/compiler/dense_switch.m index 51f4eda7d..b1ffe098d 100644 --- a/compiler/dense_switch.m +++ b/compiler/dense_switch.m @@ -54,7 +54,6 @@ :- import_module backend_libs.switch_util. :- import_module check_hlds.type_util. :- import_module hlds.hlds_data. -:- import_module hlds.hlds_goal. :- import_module hlds.hlds_llds. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_goal. diff --git a/compiler/dependency_graph.m b/compiler/dependency_graph.m index 49cad0174..b43fb35bf 100644 --- a/compiler/dependency_graph.m +++ b/compiler/dependency_graph.m @@ -128,7 +128,6 @@ :- import_module map. :- import_module maybe. :- import_module multi_map. -:- import_module pair. :- import_module set. :- import_module std_util. :- import_module term. diff --git a/compiler/deps_map.m b/compiler/deps_map.m index 663e08dc2..fb604447f 100644 --- a/compiler/deps_map.m +++ b/compiler/deps_map.m @@ -83,7 +83,6 @@ :- implementation. -:- import_module libs.globals. :- import_module libs.timestamp. :- import_module parse_tree.error_util. :- import_module parse_tree.file_kind. @@ -94,11 +93,8 @@ :- import_module parse_tree.read_modules. :- import_module parse_tree.status. -:- import_module assoc_list. :- import_module cord. :- import_module list. -:- import_module pair. -:- import_module require. :- import_module set. %-----------------------------------------------------------------------------% diff --git a/compiler/det_analysis.m b/compiler/det_analysis.m index 832d03237..7759d3e2f 100644 --- a/compiler/det_analysis.m +++ b/compiler/det_analysis.m @@ -125,10 +125,8 @@ :- import_module libs.globals. :- import_module libs.options. :- import_module parse_tree.mercury_to_mercury. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_detism. :- import_module parse_tree.prog_out. -:- import_module parse_tree.prog_type. :- import_module parse_tree.set_of_var. :- import_module assoc_list. @@ -138,7 +136,6 @@ :- import_module map. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. diff --git a/compiler/det_util.m b/compiler/det_util.m index ee860b518..d3dd9c7c0 100644 --- a/compiler/det_util.m +++ b/compiler/det_util.m @@ -129,9 +129,6 @@ :- implementation. -:- import_module libs. -:- import_module libs.globals. -:- import_module libs.options. :- import_module parse_tree.prog_type. :- import_module parse_tree.prog_util. diff --git a/compiler/disj_gen.m b/compiler/disj_gen.m index 880e82505..dd90a58f6 100644 --- a/compiler/disj_gen.m +++ b/compiler/disj_gen.m @@ -46,7 +46,6 @@ :- import_module libs.globals. :- import_module libs.options. :- import_module ll_backend.code_gen. -:- import_module ll_backend.code_loc_dep. :- import_module ll_backend.continuation_info. :- import_module ll_backend.global_data. :- import_module ll_backend.lookup_util. diff --git a/compiler/distance_granularity.m b/compiler/distance_granularity.m index 6034c910a..155e2dcd6 100644 --- a/compiler/distance_granularity.m +++ b/compiler/distance_granularity.m @@ -166,7 +166,6 @@ :- import_module maybe. :- import_module require. :- import_module string. -:- import_module set. :- import_module term. %-----------------------------------------------------------------------------% diff --git a/compiler/du_type_layout.m b/compiler/du_type_layout.m index 26a024709..49a1b444a 100644 --- a/compiler/du_type_layout.m +++ b/compiler/du_type_layout.m @@ -24,6 +24,7 @@ :- import_module libs.globals. :- import_module libs.options. +:- import_module bool. :- import_module int. :- import_module map. :- import_module require. diff --git a/compiler/equiv_type.m b/compiler/equiv_type.m index 0351cf656..b21de4ebf 100644 --- a/compiler/equiv_type.m +++ b/compiler/equiv_type.m @@ -95,7 +95,6 @@ :- import_module mdbcomp.prim_data. :- import_module mdbcomp.sym_name. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_util. :- import_module parse_tree.prog_type. @@ -103,7 +102,6 @@ :- import_module parse_tree.status. :- import_module assoc_list. -:- import_module bool. :- import_module pair. :- import_module require. :- import_module set. diff --git a/compiler/equiv_type_hlds.m b/compiler/equiv_type_hlds.m index dccb21da5..11fc9978e 100644 --- a/compiler/equiv_type_hlds.m +++ b/compiler/equiv_type_hlds.m @@ -52,7 +52,6 @@ :- import_module assoc_list. :- import_module bool. -:- import_module io. :- import_module list. :- import_module map. :- import_module maybe. diff --git a/compiler/erl_code_util.m b/compiler/erl_code_util.m index 7ee631d98..b5e144b6a 100644 --- a/compiler/erl_code_util.m +++ b/compiler/erl_code_util.m @@ -217,7 +217,6 @@ :- import_module int. :- import_module map. :- import_module require. -:- import_module set. :- import_module term. :- import_module varset. diff --git a/compiler/erl_unify_gen.m b/compiler/erl_unify_gen.m index 4472979bb..a8e391dfe 100644 --- a/compiler/erl_unify_gen.m +++ b/compiler/erl_unify_gen.m @@ -84,7 +84,6 @@ :- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. :- import_module mdbcomp.sym_name. -:- import_module parse_tree.prog_data. :- import_module int. :- import_module list. diff --git a/compiler/error_util.m b/compiler/error_util.m index e10965aec..484778bf2 100644 --- a/compiler/error_util.m +++ b/compiler/error_util.m @@ -509,7 +509,6 @@ :- import_module char. :- import_module cord. :- import_module int. -:- import_module list. :- import_module map. :- import_module pair. :- import_module require. diff --git a/compiler/exception_analysis.m b/compiler/exception_analysis.m index 7f418e84a..2df66a53a 100644 --- a/compiler/exception_analysis.m +++ b/compiler/exception_analysis.m @@ -129,7 +129,6 @@ :- import_module check_hlds.type_util. :- import_module hlds.hlds_goal. -:- import_module hlds.hlds_pred. :- import_module hlds.vartypes. :- import_module libs.file_util. :- import_module libs.globals. diff --git a/compiler/export.m b/compiler/export.m index b01cba7b6..1e3330e02 100644 --- a/compiler/export.m +++ b/compiler/export.m @@ -99,7 +99,6 @@ :- import_module mdbcomp.prim_data. :- import_module parse_tree.file_names. :- import_module parse_tree.module_cmds. -:- import_module parse_tree.prog_foreign. :- import_module parse_tree.prog_util. :- import_module parse_tree.status. diff --git a/compiler/fact_table.m b/compiler/fact_table.m index d493a194e..4e49bb945 100644 --- a/compiler/fact_table.m +++ b/compiler/fact_table.m @@ -105,8 +105,6 @@ :- import_module libs.file_util. :- import_module libs.globals. :- import_module libs.options. -:- import_module ll_backend.code_util. -:- import_module ll_backend.llds. :- import_module ll_backend.llds_out. :- import_module ll_backend.llds_out.llds_out_data. :- import_module mdbcomp.prim_data. diff --git a/compiler/field_access.m b/compiler/field_access.m index ade6fa602..ed53a0c95 100644 --- a/compiler/field_access.m +++ b/compiler/field_access.m @@ -109,7 +109,6 @@ :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_io_sym_name. -:- import_module bool. :- import_module int. :- import_module require. :- import_module term. diff --git a/compiler/file_names.m b/compiler/file_names.m index fb8ab1f51..2e66cc9e9 100644 --- a/compiler/file_names.m +++ b/compiler/file_names.m @@ -146,10 +146,8 @@ :- implementation. -:- import_module libs.globals. :- import_module libs.handle_options. :- import_module libs.options. -:- import_module mdbcomp.sym_name. :- import_module parse_tree.java_names. :- import_module parse_tree.source_file_map. diff --git a/compiler/float_regs.m b/compiler/float_regs.m index 2fac073fb..77b30b9c5 100644 --- a/compiler/float_regs.m +++ b/compiler/float_regs.m @@ -160,7 +160,6 @@ :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_type. :- import_module parse_tree.set_of_var. -:- import_module transform_hlds.dependency_graph. :- import_module transform_hlds.lambda. :- import_module assoc_list. diff --git a/compiler/follow_code.m b/compiler/follow_code.m index 0302f02f2..7f5a90406 100644 --- a/compiler/follow_code.m +++ b/compiler/follow_code.m @@ -58,7 +58,6 @@ :- import_module bool. :- import_module list. :- import_module require. -:- import_module set. %-----------------------------------------------------------------------------% diff --git a/compiler/foreign.m b/compiler/foreign.m index 6040f540c..b3d47bc4c 100644 --- a/compiler/foreign.m +++ b/compiler/foreign.m @@ -149,21 +149,10 @@ :- implementation. -:- import_module hlds.code_model. -:- import_module hlds.hlds_data. -:- import_module hlds.hlds_module. -:- import_module hlds.hlds_pred. :- import_module libs. -:- import_module libs.globals. -:- import_module parse_tree.error_util. -:- import_module parse_tree.prog_out. :- import_module parse_tree.prog_type. -:- import_module parse_tree.prog_util. -:- import_module assoc_list. :- import_module int. -:- import_module list. -:- import_module pair. :- import_module require. :- import_module string. :- import_module term. diff --git a/compiler/format_call.m b/compiler/format_call.m index acff117a7..5efb91523 100644 --- a/compiler/format_call.m +++ b/compiler/format_call.m @@ -166,20 +166,15 @@ :- import_module parse_tree.set_of_var. :- import_module bool. -:- import_module char. :- import_module counter. -:- import_module exception. :- import_module getopt_io. :- import_module map. -:- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module set_tree234. :- import_module string. :- import_module string.parse_util. :- import_module term. -:- import_module univ. :- import_module varset. %---------------------------------------------------------------------------% diff --git a/compiler/global_data.m b/compiler/global_data.m index bf35bdd40..ec39e31c7 100644 --- a/compiler/global_data.m +++ b/compiler/global_data.m @@ -153,8 +153,6 @@ :- implementation. -:- import_module ll_backend.layout. - :- import_module assoc_list. :- import_module bimap. :- import_module counter. diff --git a/compiler/goal_expr_to_goal.m b/compiler/goal_expr_to_goal.m index 1846d304c..b9bd06b34 100644 --- a/compiler/goal_expr_to_goal.m +++ b/compiler/goal_expr_to_goal.m @@ -46,47 +46,32 @@ :- implementation. -:- import_module check_hlds.clause_to_proc. -:- import_module check_hlds.mode_errors. -:- import_module hlds.goal_util. -:- import_module hlds.hlds_args. :- import_module hlds.hlds_data. -:- import_module hlds.hlds_error_util. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_goal. :- import_module hlds.hlds_out.hlds_out_util. :- import_module hlds.hlds_pred. -:- import_module hlds.hlds_pred. -:- import_module hlds.hlds_rtti. :- import_module hlds.make_goal. :- import_module hlds.make_hlds.add_pred. :- import_module hlds.make_hlds.field_access. -:- import_module hlds.make_hlds.make_hlds_warn. :- import_module hlds.make_hlds.superhomogeneous. -:- import_module hlds.pred_table. -:- import_module hlds.quantification. :- import_module libs.globals. -:- import_module libs.options. :- import_module mdbcomp.builtin_modules. :- import_module mdbcomp.sym_name. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.module_qual. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_io_util. :- import_module parse_tree.prog_mode. -:- import_module parse_tree.prog_out. :- import_module parse_tree.prog_util. :- import_module parse_tree.prog_rename. :- import_module assoc_list. :- import_module bool. :- import_module cord. -:- import_module int. :- import_module io. :- import_module map. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module varset. diff --git a/compiler/goal_form.m b/compiler/goal_form.m index 67196e457..29d8b383f 100644 --- a/compiler/goal_form.m +++ b/compiler/goal_form.m @@ -199,12 +199,10 @@ :- implementation. :- import_module hlds.code_model. -:- import_module hlds.hlds_goal. :- import_module parse_tree.prog_data. :- import_module transform_hlds.exception_analysis. :- import_module transform_hlds.term_constr_main. -:- import_module bool. :- import_module int. :- import_module map. :- import_module maybe. diff --git a/compiler/goal_path.m b/compiler/goal_path.m index fe5b2157e..96470608e 100644 --- a/compiler/goal_path.m +++ b/compiler/goal_path.m @@ -64,7 +64,6 @@ :- implementation. :- import_module check_hlds.type_util. -:- import_module hlds.hlds_goal. :- import_module mdbcomp. :- import_module parse_tree.prog_data. @@ -73,7 +72,6 @@ :- import_module int. :- import_module list. :- import_module map. -:- import_module maybe. :- import_module pair. :- import_module require. diff --git a/compiler/goal_util.m b/compiler/goal_util.m index 58baaa8b7..71b89cfbc 100644 --- a/compiler/goal_util.m +++ b/compiler/goal_util.m @@ -444,7 +444,6 @@ :- import_module check_hlds.inst_match. :- import_module check_hlds.type_util. :- import_module hlds.goal_form. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_detism. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_type. diff --git a/compiler/hhf.m b/compiler/hhf.m index 1df00122f..8cfa67d67 100644 --- a/compiler/hhf.m +++ b/compiler/hhf.m @@ -56,7 +56,6 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module solutions. :- import_module term. :- import_module varset. diff --git a/compiler/hlds_clauses.m b/compiler/hlds_clauses.m index 8f6a160ce..4a414f0eb 100644 --- a/compiler/hlds_clauses.m +++ b/compiler/hlds_clauses.m @@ -247,7 +247,6 @@ :- import_module int. :- import_module map. :- import_module require. -:- import_module term. :- import_module varset. :- type clause_item_numbers diff --git a/compiler/hlds_code_util.m b/compiler/hlds_code_util.m index 466202a7e..a274125f0 100644 --- a/compiler/hlds_code_util.m +++ b/compiler/hlds_code_util.m @@ -71,7 +71,6 @@ :- import_module check_hlds.mode_util. :- import_module check_hlds.type_util. -:- import_module hlds.hlds_pred. :- import_module libs.globals. :- import_module mdbcomp.sym_name. :- import_module parse_tree.prog_mode. diff --git a/compiler/hlds_data.m b/compiler/hlds_data.m index 29a0eb114..25df812d2 100644 --- a/compiler/hlds_data.m +++ b/compiler/hlds_data.m @@ -37,12 +37,10 @@ :- import_module parse_tree.prog_type. :- import_module parse_tree.prog_type_subst. -:- import_module cord. :- import_module int. :- import_module multi_map. :- import_module pair. :- import_module require. -:- import_module solutions. :- import_module varset. %---------------------------------------------------------------------------% @@ -1709,7 +1707,7 @@ mode_table_optimize(!ModeDefns) :- :- type instance_id == int. - % Information about a single `instance' declaration + % Information about a single `instance' declaration. % :- type hlds_instance_defn ---> hlds_instance_defn( @@ -1717,6 +1715,8 @@ mode_table_optimize(!ModeDefns) :- instance_module :: module_name, % Import status of the instance declaration. + % XXX This can be set to abstract_imported even if + % the instance is NOT imported. instance_status :: import_status, % Context of declaration. diff --git a/compiler/hlds_desc.m b/compiler/hlds_desc.m index c72556729..0a19c7734 100644 --- a/compiler/hlds_desc.m +++ b/compiler/hlds_desc.m @@ -50,15 +50,11 @@ :- implementation. -:- import_module hlds.hlds_out. -:- import_module hlds.hlds_out.hlds_out_util. :- import_module hlds.hlds_pred. :- import_module mdbcomp.sym_name. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_out. -:- import_module bool. -:- import_module list. :- import_module string. :- import_module term. diff --git a/compiler/hlds_error_util.m b/compiler/hlds_error_util.m index c5a4a0a3d..52f8c378f 100644 --- a/compiler/hlds_error_util.m +++ b/compiler/hlds_error_util.m @@ -124,7 +124,6 @@ :- import_module int. :- import_module string. -:- import_module list. :- import_module require. :- import_module term. diff --git a/compiler/hlds_goal.m b/compiler/hlds_goal.m index 0f8d6bd16..0ea37bb6f 100644 --- a/compiler/hlds_goal.m +++ b/compiler/hlds_goal.m @@ -1754,15 +1754,11 @@ :- implementation. -:- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.prog_detism. -:- import_module parse_tree.prog_mode. :- import_module io. -:- import_module map. :- import_module require. :- import_module string. -:- import_module varset. %-----------------------------------------------------------------------------% diff --git a/compiler/hlds_llds.m b/compiler/hlds_llds.m index f80ef0bb1..c04d1cd77 100644 --- a/compiler/hlds_llds.m +++ b/compiler/hlds_llds.m @@ -307,7 +307,6 @@ :- implementation. :- import_module assoc_list. -:- import_module list. :- import_module pair. :- import_module require. :- import_module string. diff --git a/compiler/hlds_module.m b/compiler/hlds_module.m index ee643a354..25b71c15b 100644 --- a/compiler/hlds_module.m +++ b/compiler/hlds_module.m @@ -239,6 +239,31 @@ % :- pred module_info_optimize(module_info::in, module_info::out) is det. +:- type avail_module_map == map(module_name, avail_module_entry). +:- type avail_module_entry + ---> avail_module_entry( + % ms_interface iff any avail_module has ms_interface. + module_section, + + % import_decl iff any avail_module has import_decl. + import_or_use, + + % The locations of the *explicit* import_module and + % use_import declarations, in the *source* of the modul. + % The implicit ones aren't in the list, and neither + % are the imports and uses read in from interface + % and optimization files, so it is possible for the list + % to be empty. + list(avail_module) + ). + +:- type avail_module + ---> avail_module( + module_section, + import_or_use, + prog_context + ). + % The getter predicates. Please keep the order of declarations here % and the order of the clauses below in sync with the order of the % fields in the module_info and module_sub_info types. @@ -309,12 +334,10 @@ table_struct_map::out) is det. :- pred module_info_get_mm_tabling_info(module_info::in, mm_tabling_info::out) is det. -:- pred module_info_get_imported_module_names(module_info::in, - set(module_name)::out) is det. +:- pred module_info_get_avail_module_map(module_info::in, + avail_module_map::out) is det. :- pred module_info_get_indirectly_imported_module_names(module_info::in, set(module_name)::out) is det. -:- pred module_info_get_interface_module_names(module_info::in, - set(module_name)::out) is det. :- pred module_info_get_used_modules(module_info::in, used_modules::out) is det. :- pred module_info_get_maybe_complexity_proc_map(module_info::in, @@ -542,11 +565,12 @@ %---------------------% -:- pred module_add_imported_module_name(import_status::in, - module_name::in, module_info::in, module_info::out) is det. +:- pred module_add_avail_module_name(module_name::in, + module_section::in, import_or_use::in, maybe(prog_context)::in, + module_info::in, module_info::out) is det. -:- pred module_add_indirectly_imported_module_name( - module_name::in, module_info::in, module_info::out) is det. +:- pred module_add_indirectly_imported_module_name(module_name::in, + module_info::in, module_info::out) is det. % Return the set of the visible modules. These are % @@ -600,7 +624,6 @@ :- import_module transform_hlds.mmc_analysis. :- import_module assoc_list. -:- import_module bool. :- import_module counter. :- import_module int. :- import_module require. @@ -750,17 +773,13 @@ % The names of all the directly imported modules % (used during type checking, and by the MLDS back-end). - mri_imported_module_names :: set(module_name), + mri_avail_module_map :: avail_module_map, % The names of all the indirectly imported modules % (used by the MLDS back-end). mri_indirectly_imported_module_names :: set(module_name), - % The names of all the modules imported directly - % in the interface. (Used by unused_imports analysis). - mri_interface_module_names :: set(module_name), - % The modules which have already been calculated as being used. % Currently this is the module imports inherited from the % parent modules plus those calculated during expansion of @@ -880,16 +899,30 @@ module_info_init(AugCompUnit, DumpBaseFileName, Globals, QualifierInfo, % separately, or at least record for each import (and use) whether % it was explicit or implicit, and one (or more) context where either % the explicit imported was requested, or the implicit import was required. - ImportedModules = set.union_list([ + ImportedAvailModules = set.union_list([ + SrcImportDeps, + DirectIntImportDeps, + IndirectIntImportDeps, + OptImportDeps, + IntForOptImportDeps]), + UsedAvailModules = set.union_list([ SrcImportDeps, SrcUseDeps, DirectIntImportDeps, DirectIntUseDeps, IndirectIntImportDeps, IndirectIntUseDeps, OptImportDeps, OptUseDeps, IntForOptImportDeps, IntForOptUseDeps]), + OnlyUsedAvailModules = + set.difference(UsedAvailModules, ImportedAvailModules), + + map.init(AvailModuleMap0), + set.fold(add_implicit_avail_module(import_decl), ImportedAvailModules, + AvailModuleMap0, AvailModuleMap1), + set.fold(add_implicit_avail_module(use_decl), OnlyUsedAvailModules, + AvailModuleMap1, AvailModuleMap), set.init(IndirectlyImportedModules), - set.init(InterfaceModuleSpecs), UsedModules = used_modules_init, + MaybeComplexityMap = no, ComplexityProcInfos = [], @@ -916,8 +949,7 @@ module_info_init(AugCompUnit, DumpBaseFileName, Globals, QualifierInfo, MustBeStratifiedPreds, StratPreds, UnusedArgInfo, TrailingInfo, TablingStructMap, MM_TablingInfo, LambdasPerContext, AtomicsPerContext, - ImportedModules, IndirectlyImportedModules, - InterfaceModuleSpecs, UsedModules, + AvailModuleMap, IndirectlyImportedModules, UsedModules, MaybeComplexityMap, ComplexityProcInfos, AnalysisInfo, UserInitPredCNames, UserFinalPredCNames, StructureReusePredIds, @@ -937,6 +969,13 @@ module_info_init(AugCompUnit, DumpBaseFileName, Globals, QualifierInfo, PredicateTable, TypeTable, NoTagTypes, InstTable, ModeTable, CtorTable, ClassTable, FieldNameTable). +:- pred add_implicit_avail_module(import_or_use::in, module_name::in, + avail_module_map::in, avail_module_map::out) is det. + +add_implicit_avail_module(ImportOrUse, ModuleName, !AvailModuleMap) :- + Entry = avail_module_entry(ms_implementation, ImportOrUse, []), + map.det_insert(ModuleName, Entry, !AvailModuleMap). + module_info_optimize(!ModuleInfo) :- % Currently, all the calls to *_table_optimize are no-ops. % We keep them, and this predicate, in case that changes in thr future. @@ -1072,12 +1111,10 @@ module_info_get_lambdas_per_context(MI, X) :- X = MI ^ mi_rare_info ^ mri_lambdas_per_context. module_info_get_atomics_per_context(MI, X) :- X = MI ^ mi_rare_info ^ mri_atomics_per_context. -module_info_get_imported_module_names(MI, X) :- - X = MI ^ mi_rare_info ^ mri_imported_module_names. +module_info_get_avail_module_map(MI, X) :- + X = MI ^ mi_rare_info ^ mri_avail_module_map. module_info_get_indirectly_imported_module_names(MI, X) :- X = MI ^ mi_rare_info ^ mri_indirectly_imported_module_names. -module_info_get_interface_module_names(MI, X) :- - X = MI ^ mi_rare_info ^ mri_interface_module_names. module_info_get_used_modules(MI, X) :- X = MI ^ mi_rare_info ^ mri_used_modules. module_info_get_maybe_complexity_proc_map(MI, X) :- @@ -1473,22 +1510,52 @@ module_info_next_atomic_count(Context, Count, !MI) :- %---------------------% -module_add_imported_module_name(IStat, AddedModuleSpecifier, !MI) :- - ImportSpecifiers0 = !.MI ^ mi_rare_info ^ mri_imported_module_names, - set.insert(AddedModuleSpecifier, ImportSpecifiers0, ImportSpecifiers), - !MI ^ mi_rare_info ^ mri_imported_module_names := ImportSpecifiers, - - Exported = status_is_exported_to_non_submodules(IStat), +module_add_avail_module_name(ModuleName, NewSection, NewImportOrUse, + MaybeContext, !MI) :- ( - Exported = yes, - InterfaceSpecifiers0 = - !.MI ^ mi_rare_info ^ mri_interface_module_names, - set.insert(AddedModuleSpecifier, - InterfaceSpecifiers0, InterfaceSpecifiers), - !MI ^ mi_rare_info ^ mri_interface_module_names := - InterfaceSpecifiers + MaybeContext = no, + NewAvails = [] ; - Exported = no + MaybeContext = yes(Context), + NewAvails = [avail_module(NewSection, NewImportOrUse, Context)] + ), + AvailMap0 = !.MI ^ mi_rare_info ^ mri_avail_module_map, + ( if map.search(AvailMap0, ModuleName, OldEntry) then + OldEntry = avail_module_entry(OldSection, OldImportOrUse, OldAvails), + combine_old_new_avail_attrs(OldSection, NewSection, + OldImportOrUse, NewImportOrUse, Section, ImportOrUse), + Avails = NewAvails ++ OldAvails, + NewEntry = avail_module_entry(Section, ImportOrUse, Avails), + map.det_update(ModuleName, NewEntry, AvailMap0, AvailMap) + else + NewEntry = avail_module_entry(NewSection, NewImportOrUse, NewAvails), + map.det_insert(ModuleName, NewEntry, AvailMap0, AvailMap) + ), + !MI ^ mi_rare_info ^ mri_avail_module_map := AvailMap. + +:- pred combine_old_new_avail_attrs(module_section::in, module_section::in, + import_or_use::in, import_or_use::in, + module_section::out, import_or_use::out) is det. + +combine_old_new_avail_attrs(OldSection, NewSection, + OldImportOrUse, NewImportOrUse, Section, ImportOrUse) :- + ( if + ( OldSection = ms_interface + ; NewSection = ms_interface + ) + then + Section = ms_interface + else + Section = ms_implementation + ), + ( if + ( OldImportOrUse = import_decl + ; NewImportOrUse = import_decl + ) + then + ImportOrUse = import_decl + else + ImportOrUse = use_decl ). module_add_indirectly_imported_module_name(AddedModuleSpecifier, !MI) :- @@ -1498,20 +1565,22 @@ module_add_indirectly_imported_module_name(AddedModuleSpecifier, !MI) :- module_info_get_visible_modules(ModuleInfo, !:VisibleModules) :- module_info_get_name(ModuleInfo, ThisModule), - module_info_get_imported_module_names(ModuleInfo, ImportedModules), + module_info_get_avail_module_map(ModuleInfo, AvailModuleMap), - !:VisibleModules = ImportedModules, + map.keys(AvailModuleMap, AvailModules), + set.list_to_set(AvailModules, !:VisibleModules), set.insert(ThisModule, !VisibleModules), set.insert_list(get_ancestors(ThisModule), !VisibleModules). module_info_get_all_deps(ModuleInfo, AllImports) :- module_info_get_name(ModuleInfo, ModuleName), Parents = get_ancestors(ModuleName), - module_info_get_imported_module_names(ModuleInfo, DirectImports), + module_info_get_avail_module_map(ModuleInfo, AvailModuleMap), + map.keys(AvailModuleMap, DirectImports), module_info_get_indirectly_imported_module_names(ModuleInfo, IndirectImports), - AllImports = set.union_list([IndirectImports, DirectImports, - set.list_to_set(Parents)]). + AllImports = set.union_list([IndirectImports, + set.list_to_set(DirectImports), set.list_to_set(Parents)]). module_info_add_parent_to_used_modules(ModuleSpecifier, !MI) :- module_info_get_used_modules(!.MI, UsedModules0), diff --git a/compiler/hlds_out_mode.m b/compiler/hlds_out_mode.m index 18a5f1a4a..9cabbb36b 100644 --- a/compiler/hlds_out_mode.m +++ b/compiler/hlds_out_mode.m @@ -106,7 +106,6 @@ :- implementation. :- import_module check_hlds.mode_util. -:- import_module hlds.instmap. :- import_module mdbcomp.prim_data. :- import_module mdbcomp.sym_name. :- import_module parse_tree.prog_io_util. @@ -119,7 +118,6 @@ :- import_module set. :- import_module string. :- import_module term. -:- import_module term_io. :- import_module varset. %-----------------------------------------------------------------------------% diff --git a/compiler/hlds_out_module.m b/compiler/hlds_out_module.m index d448999d7..6b05e2246 100644 --- a/compiler/hlds_out_module.m +++ b/compiler/hlds_out_module.m @@ -51,6 +51,7 @@ :- import_module libs.options. :- import_module mdbcomp.sym_name. :- import_module parse_tree.mercury_to_mercury. +:- import_module parse_tree.prog_item. :- import_module parse_tree.prog_out. :- import_module assoc_list. @@ -92,9 +93,8 @@ write_hlds(Indent, ModuleInfo, !IO) :- true ; ( string.contains_char(DumpOptions, 'I') -> - module_info_get_imported_module_names(ModuleInfo, - ImportedModuleNames), - write_imports(Indent, ImportedModuleNames, !IO) + module_info_get_avail_module_map(ModuleInfo, AvailModuleMap), + map.foldl(write_avail_entry(Indent), AvailModuleMap, !IO) ; true ), @@ -163,17 +163,32 @@ write_footer(Indent, Module, !IO) :- %-----------------------------------------------------------------------------% % -% Write out the imports. +% Write out the imports and uses. % -:- pred write_imports(int::in, set(module_name)::in, io::di, io::uo) - is det. +:- pred write_avail_entry(int::in, module_name::in, avail_module_entry::in, + io::di, io::uo) is det. -write_imports(Indent, ImportSet, !IO) :- +write_avail_entry(Indent, ModuleName, Entry, !IO) :- + Entry = avail_module_entry(Section, ImportOrUse, Avails), + ( + ImportOrUse = import_decl, + ImportOrUseDecl = ":- import_module " + ; + ImportOrUse = use_decl, + ImportOrUseDecl = ":- use_module " + ), write_indent(Indent, !IO), - io.write_string(":- import_module ", !IO), - io.write_list(set.to_sorted_list(ImportSet), ", ", write_sym_name, !IO), - io.write_string(".\n\n", !IO). + io.write_string(ImportOrUseDecl, !IO), + write_module_name(ModuleName, !IO), + io.write_string(".\n", !IO), + + write_indent(Indent, !IO), + io.write_string("% ", !IO), + io.write(Section, !IO), + io.write_string(", ", !IO), + io.write(Avails, !IO), + io.write_string("\n", !IO). %-----------------------------------------------------------------------------% % @@ -539,32 +554,36 @@ write_instances(Info, Indent, InstanceTable, !IO) :- pair(class_id, list(hlds_instance_defn))::in, io::di, io::uo) is det. write_instance_defns(Info, Indent, ClassId - InstanceDefns, !IO) :- + io.nl(!IO), write_indent(Indent, !IO), - io.write_string("% ", !IO), + io.write_string("% Instances for class ", !IO), write_class_id(ClassId, !IO), io.write_string(":\n", !IO), - io.write_list(InstanceDefns, "\n", write_instance_defn(Info, Indent), - !IO). + io.write_list(InstanceDefns, "\n", + write_instance_defn(Info, Indent + 1), !IO). :- pred write_instance_defn(hlds_out_info::in, int::in, hlds_instance_defn::in, io::di, io::uo) is det. write_instance_defn(Info, Indent, InstanceDefn, !IO) :- - InstanceDefn = hlds_instance_defn(_InstanceModule, _Status, + InstanceDefn = hlds_instance_defn(_InstanceModule, Status, Context, Constraints, Types, OriginalTypes, Body, MaybePredProcIds, VarSet, ProofMap), + % Separate this instance from any previous ones, or the class id. + io.nl(!IO), + term.context_file(Context, FileName), term.context_line(Context, LineNumber), - ( FileName \= "" -> + ( FileName = "" -> + true + ; write_indent(Indent, !IO), io.write_string("% context: file `", !IO), io.write_string(FileName, !IO), io.write_string("', line ", !IO), io.write_int(LineNumber, !IO), io.write_string("\n", !IO) - ; - true ), DumpOptions = Info ^ hoi_dump_hlds_options, @@ -575,18 +594,21 @@ write_instance_defn(Info, Indent, InstanceDefn, !IO) :- ), % Curry the varset for term_io.write_variable/4. - PrintTerm = (pred(TypeName::in, IO0::di, IO::uo) is det :- - mercury_output_type(VarSet, VarNamePrint, TypeName, IO0, IO) - ), + PrintTerm = mercury_output_type(VarSet, VarNamePrint), write_indent(Indent, !IO), io.write_string("% Types: ", !IO), - io.write_list(Types, ", ", PrintTerm, !IO), + io.write_list(Types, ", ", mercury_output_type(VarSet, VarNamePrint), !IO), io.nl(!IO), write_indent(Indent, !IO), io.write_string("% Original types: ", !IO), io.write_list(OriginalTypes, ", ", PrintTerm, !IO), io.nl(!IO), + write_indent(Indent, !IO), + io.write_string("% Status: ", !IO), + io.write_string(import_status_to_string(Status), !IO), + io.nl(!IO), + write_indent(Indent, !IO), io.write_string("% Constraints: ", !IO), io.write_list(Constraints, ", ", @@ -613,8 +635,7 @@ write_instance_defn(Info, Indent, InstanceDefn, !IO) :- ; MaybePredProcIds = no ), - write_constraint_proof_map(VarSet, VarNamePrint, Indent, ProofMap, !IO), - io.nl(!IO). + write_constraint_proof_map(VarSet, VarNamePrint, Indent, ProofMap, !IO). %-----------------------------------------------------------------------------% % diff --git a/compiler/hlds_pred.m b/compiler/hlds_pred.m index e028955b5..2ae24addb 100644 --- a/compiler/hlds_pred.m +++ b/compiler/hlds_pred.m @@ -56,14 +56,11 @@ :- import_module backend_libs. :- import_module backend_libs.builtin_ops. :- import_module check_hlds.inst_match. -:- import_module check_hlds.mode_errors. :- import_module check_hlds.mode_util. :- import_module check_hlds.type_util. :- import_module hlds.goal_form. :- import_module hlds.goal_util. :- import_module hlds.hlds_args. -:- import_module hlds.hlds_rtti. -:- import_module hlds.special_pred. :- import_module libs.options. :- import_module parse_tree.prog_detism. :- import_module parse_tree.prog_type. diff --git a/compiler/il_peephole.m b/compiler/il_peephole.m index d58facce8..c2bc1e401 100644 --- a/compiler/il_peephole.m +++ b/compiler/il_peephole.m @@ -59,7 +59,6 @@ :- import_module ml_backend.ilds. :- import_module assoc_list. -:- import_module bool. :- import_module int. :- import_module pair. :- import_module string. diff --git a/compiler/inlining.m b/compiler/inlining.m index ead50e7e3..e2bf02be5 100644 --- a/compiler/inlining.m +++ b/compiler/inlining.m @@ -158,17 +158,13 @@ :- import_module libs.options. :- import_module libs.trace_params. :- import_module mdbcomp.sym_name. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_type. -:- import_module parse_tree.prog_type_subst. :- import_module parse_tree.set_of_var. :- import_module transform_hlds.complexity. :- import_module transform_hlds.dead_proc_elim. :- import_module transform_hlds.dependency_graph. -:- import_module bool. :- import_module int. -:- import_module list. :- import_module maybe. :- import_module multi_map. :- import_module pair. diff --git a/compiler/inst_check.m b/compiler/inst_check.m index a91a1f57b..47cb562ff 100644 --- a/compiler/inst_check.m +++ b/compiler/inst_check.m @@ -61,27 +61,15 @@ :- implementation. -:- import_module hlds. :- import_module hlds.hlds_data. -:- import_module hlds.hlds_module. -:- import_module hlds.hlds_pred. :- import_module mdbcomp. :- import_module mdbcomp.sym_name. -:- import_module parse_tree. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_out. :- import_module parse_tree.prog_type. :- import_module parse_tree.status. -:- import_module assoc_list. -:- import_module bool. -:- import_module map. -:- import_module maybe. -:- import_module multi_map. -:- import_module pair. -:- import_module string. - :- import_module assoc_list. :- import_module bool. :- import_module cord. diff --git a/compiler/inst_match.m b/compiler/inst_match.m index aac9948e8..e42b0f892 100644 --- a/compiler/inst_match.m +++ b/compiler/inst_match.m @@ -343,14 +343,12 @@ :- import_module mdbcomp. :- import_module mdbcomp.prim_data. :- import_module mdbcomp.sym_name. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_type. :- import_module bool. :- import_module int. :- import_module io. -:- import_module list. :- import_module map. :- import_module maybe. :- import_module require. diff --git a/compiler/inst_user.m b/compiler/inst_user.m index 42e9a4ee0..7e6dbd506 100644 --- a/compiler/inst_user.m +++ b/compiler/inst_user.m @@ -29,7 +29,6 @@ :- import_module check_hlds.mode_util. :- import_module hlds.hlds_data. -:- import_module mdbcomp. :- import_module parse_tree. :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_type. diff --git a/compiler/inst_util.m b/compiler/inst_util.m index d6c2ff855..d698ecec2 100644 --- a/compiler/inst_util.m +++ b/compiler/inst_util.m @@ -159,9 +159,6 @@ :- import_module parse_tree.prog_type. :- import_module int. -:- import_module list. -:- import_module map. -:- import_module pair. :- import_module require. :- import_module set. diff --git a/compiler/instmap.m b/compiler/instmap.m index 408d81fbb..867b0443f 100644 --- a/compiler/instmap.m +++ b/compiler/instmap.m @@ -364,14 +364,12 @@ :- import_module check_hlds.inst_util. :- import_module check_hlds.mode_util. :- import_module check_hlds.type_util. -:- import_module parse_tree.prog_data. :- import_module bool. :- import_module int. :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module std_util. :- import_module string. :- import_module term. diff --git a/compiler/intermod.m b/compiler/intermod.m index 800edb576..f217451f2 100644 --- a/compiler/intermod.m +++ b/compiler/intermod.m @@ -115,14 +115,12 @@ :- import_module hlds.special_pred. :- import_module hlds.vartypes. :- import_module libs.file_util. -:- import_module libs.globals. :- import_module libs.options. :- import_module mdbcomp.prim_data. :- import_module mdbcomp.sym_name. :- import_module parse_tree.file_kind. :- import_module parse_tree.file_names. :- import_module parse_tree.get_dependencies. -:- import_module parse_tree.item_util. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.modules. :- import_module parse_tree.prog_data. @@ -146,7 +144,6 @@ :- import_module solutions. :- import_module string. :- import_module term. -:- import_module term_io. :- import_module varset. %-----------------------------------------------------------------------------% @@ -1296,14 +1293,11 @@ write_intermod_info_body(IntermodInfo, !IO) :- set.to_sorted_list(Preds0, Preds), set.to_sorted_list(PredDecls0, PredDecls), - module_info_get_imported_module_names(ModuleInfo, UsedModules), - % XXX UsedModules could and should be reduced to the set of modules - % that are actually needed by the items being written. - ( if set.is_empty(UsedModules) then - true - else - set.fold(intermod_write_use_module, UsedModules, !IO) - ), + module_info_get_avail_module_map(ModuleInfo, AvailModuleMap), + % XXX We could and should reduce AvailModules to the set of modules + % that are *actually needed* by the items being written. + map.keys(AvailModuleMap, AvailModuleNames), + list.foldl(intermod_write_use_module, AvailModuleNames, !IO), module_info_get_globals(ModuleInfo, Globals), OutInfo0 = init_hlds_out_info(Globals, output_mercury), diff --git a/compiler/introduce_parallelism.m b/compiler/introduce_parallelism.m index cfb527510..076632d5b 100644 --- a/compiler/introduce_parallelism.m +++ b/compiler/introduce_parallelism.m @@ -58,7 +58,6 @@ :- import_module transform_hlds.implicit_parallelism.push_goals_together. :- import_module assoc_list. -:- import_module bool. :- import_module list. :- import_module map. :- import_module maybe. diff --git a/compiler/item_util.m b/compiler/item_util.m index 68ce05bd4..a1413a972 100644 --- a/compiler/item_util.m +++ b/compiler/item_util.m @@ -66,10 +66,7 @@ :- import_module parse_tree.prog_foreign. :- import_module parse_tree.prog_type. -:- import_module cord. -:- import_module int. :- import_module maybe. -:- import_module term. %-----------------------------------------------------------------------------% diff --git a/compiler/lambda.m b/compiler/lambda.m index e47585eb7..d85d5bdcd 100644 --- a/compiler/lambda.m +++ b/compiler/lambda.m @@ -140,12 +140,10 @@ :- import_module check_hlds.type_util. :- import_module hlds.code_model. :- import_module hlds.goal_util. -:- import_module hlds.hlds_data. :- import_module hlds.pred_table. :- import_module hlds.quantification. :- import_module libs.globals. :- import_module libs.options. -:- import_module mdbcomp.prim_data. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_type. :- import_module parse_tree.prog_util. diff --git a/compiler/layout_out.m b/compiler/layout_out.m index 5d5da6c8a..cbc92d262 100644 --- a/compiler/layout_out.m +++ b/compiler/layout_out.m @@ -189,7 +189,6 @@ :- import_module map. :- import_module pair. :- import_module require. -:- import_module std_util. :- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/live_vars.m b/compiler/live_vars.m index e314f72bb..0da8914c2 100644 --- a/compiler/live_vars.m +++ b/compiler/live_vars.m @@ -84,11 +84,8 @@ :- import_module hlds.arg_info. :- import_module hlds.code_model. :- import_module hlds.goal_form. -:- import_module hlds.hlds_goal. -:- import_module hlds.hlds_llds. :- import_module hlds.hlds_rtti. :- import_module hlds.instmap. -:- import_module parse_tree.prog_data. :- import_module assoc_list. :- import_module enum. diff --git a/compiler/liveness.m b/compiler/liveness.m index 0452a696a..f0a09acd4 100644 --- a/compiler/liveness.m +++ b/compiler/liveness.m @@ -202,7 +202,6 @@ :- import_module ll_backend.trace_gen. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_data. -:- import_module parse_tree.set_of_var. :- import_module assoc_list. :- import_module bool. diff --git a/compiler/llds_out_instr.m b/compiler/llds_out_instr.m index 3ad01933b..35a5f6f5b 100644 --- a/compiler/llds_out_instr.m +++ b/compiler/llds_out_instr.m @@ -82,7 +82,6 @@ :- import_module check_hlds.type_util. :- import_module hlds.hlds_data. :- import_module hlds.hlds_pred. -:- import_module ll_backend.layout. :- import_module ll_backend.layout_out. :- import_module ll_backend.llds_out.llds_out_code_addr. :- import_module ll_backend.llds_out.llds_out_data. diff --git a/compiler/lookup_util.m b/compiler/lookup_util.m index 3b5aaa5dd..9027b3852 100644 --- a/compiler/lookup_util.m +++ b/compiler/lookup_util.m @@ -94,7 +94,6 @@ :- import_module int. :- import_module maybe. :- import_module require. -:- import_module set. figure_out_output_vars(CI, CLD, GoalInfo, OutVars) :- InstMapDelta = goal_info_get_instmap_delta(GoalInfo), diff --git a/compiler/loop_inv.m b/compiler/loop_inv.m index 88366601a..5ca9c86b7 100644 --- a/compiler/loop_inv.m +++ b/compiler/loop_inv.m @@ -140,7 +140,6 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. diff --git a/compiler/make_hlds.m b/compiler/make_hlds.m index 7a1e12a4f..aca8c9801 100644 --- a/compiler/make_hlds.m +++ b/compiler/make_hlds.m @@ -10,12 +10,12 @@ % Main author: fjh. % % This module converts from the parse tree structure which is read in by -% prog_io.m, into the simplified high level data structure defined in -% hlds.m. In the parse tree, the program is represented as a list of -% items; we insert each item into the appropriate symbol table, and report -% any duplicate definition errors. We also transform clause bodies from -% (A,B,C) into conj([A,B,C]) form, convert all unifications into -% super-homogenous form, and introduce implicit quantification. +% prog_io.m, into the simplified high level data structure defined in hlds.m. +% In the parse tree, the program is represented as a structure containing +% several lists of items; we insert each item into the appropriate table, +% and report any duplicate definition errors. We also transform clause bodies +% from (A,B,C) into conj([A,B,C]) form, convert all unifications into +% superhomogenous form, and introduce implicit quantification. % % WISHLIST - we should handle explicit module quantification. % @@ -38,7 +38,6 @@ :- import_module parse_tree.prog_item. :- import_module parse_tree.status. -:- import_module bool. :- import_module list. :- import_module maybe. :- import_module term. diff --git a/compiler/make_hlds_passes.m b/compiler/make_hlds_passes.m index 21d525dba..1abeffe85 100644 --- a/compiler/make_hlds_passes.m +++ b/compiler/make_hlds_passes.m @@ -66,7 +66,6 @@ :- import_module parse_tree.module_qual. :- import_module parse_tree.prog_data. -:- import_module bool. :- import_module list. %---------------------------------------------------------------------------% @@ -122,6 +121,7 @@ :- import_module parse_tree.prog_util. :- import_module recompilation. +:- import_module bool. :- import_module map. :- import_module require. :- import_module string. @@ -145,21 +145,23 @@ do_parse_tree_to_hlds(AugCompUnit, Globals, DumpBaseFileName, MQInfo0, !:FoundInvalidInstOrMode = did_not_find_invalid_inst_or_mode, !:Pass1Specs = [], add_block_decls_pass_1(SrcItemBlocks, - src_module_section_status, !FoundInvalidInstOrMode, - !ModuleInfo, !Pass1Specs), + src_module_section_status, return_yes_section, + !FoundInvalidInstOrMode, !ModuleInfo, !Pass1Specs), add_block_decls_pass_1(DirectIntItemBlocks, - int_module_section_status, !FoundInvalidInstOrMode, - !ModuleInfo, !Pass1Specs), + int_module_section_status, return_no_section, + !FoundInvalidInstOrMode, !ModuleInfo, !Pass1Specs), add_block_decls_pass_1(IndirectIntItemBlocks, - int_module_section_status, !FoundInvalidInstOrMode, - !ModuleInfo, !Pass1Specs), + int_module_section_status, return_no_section, + !FoundInvalidInstOrMode, !ModuleInfo, !Pass1Specs), add_block_decls_pass_1(IntForOptItemBlocks, - int_for_opt_module_section_status, !FoundInvalidInstOrMode, - !ModuleInfo, !Pass1Specs), - % XXX ITEM_LIST Can this pass do anything? + int_for_opt_module_section_status, return_no_section, + !FoundInvalidInstOrMode, !ModuleInfo, !Pass1Specs), + % This pass should not add any predicate declarations, but it + % sometimes does add the definitions of nominally local but + % nevertheless opt_exported insts and modes. add_block_decls_pass_1(OptItemBlocks, - opt_module_section_status, !FoundInvalidInstOrMode, - !ModuleInfo, !Pass1Specs), + opt_module_section_status, return_no_section, + !FoundInvalidInstOrMode, !ModuleInfo, !Pass1Specs), FoundInvalidInstOrMode1 = !.FoundInvalidInstOrMode, Pass1Specs = !.Pass1Specs ), @@ -283,6 +285,24 @@ do_parse_tree_to_hlds(AugCompUnit, Globals, DumpBaseFileName, MQInfo0, FoundInvalidInstOrMode = found_invalid_inst_or_mode ). +:- pred return_yes_section(src_module_section::in, maybe(module_section)::out) + is det. + +return_yes_section(SrcSection, yes(Section)) :- + ( + SrcSection = sms_interface, + Section = ms_interface + ; + ( SrcSection = sms_implementation + ; SrcSection = sms_impl_but_exported_to_submodules + ), + Section = ms_implementation + ). + +:- pred return_no_section(T::in, maybe(module_section)::out) is det. + +return_no_section(_, no). + %---------------------------------------------------------------------------% :- pred add_builtin_type_ctor_special_preds(type_ctor::in, @@ -313,21 +333,30 @@ add_builtin_type_ctor_special_preds(TypeCtor, !ModuleInfo) :- :- pred add_block_decls_pass_1(list(item_block(MS))::in, pred(MS, item_status)::in(pred(in, out) is det), + pred(MS, maybe(module_section))::in(pred(in, out) is det), found_invalid_inst_or_mode::in, found_invalid_inst_or_mode::out, module_info::in, module_info::out, list(error_spec)::in, list(error_spec)::out) is det. -add_block_decls_pass_1([], _MakeStatus, +add_block_decls_pass_1([], _MakeStatus, _MakeMaybeSrc, !FoundInvalidInstOrMode, !ModuleInfo, !Specs). -add_block_decls_pass_1([ItemBlock | ItemBlocks], MakeStatus, +add_block_decls_pass_1([ItemBlock | ItemBlocks], MakeStatus, MakeMaybeSrc, !FoundInvalidInstOrMode, !ModuleInfo, !Specs) :- ItemBlock = item_block(Section, _, _Incls, Avails, Items), - MakeStatus(Section, Status), - Status = item_status(ImportStatus, _), - list.foldl(add_item_avail_pass_1(ImportStatus), Avails, !ModuleInfo), - add_item_decls_pass_1(Status, Items, + MakeStatus(Section, ItemStatus), + ItemStatus = item_status(ImportStatus, _), + MakeMaybeSrc(Section, MaybeSrcSection), + ( + MaybeSrcSection = yes(SrcSection), + AvailLocn = avail_in_src(SrcSection) + ; + MaybeSrcSection = no, + AvailLocn = avail_elsewhere(ImportStatus) + ), + list.foldl(add_item_avail_pass_1(AvailLocn), Avails, !ModuleInfo), + add_item_decls_pass_1(ItemStatus, Items, !FoundInvalidInstOrMode, !ModuleInfo, !Specs), - add_block_decls_pass_1(ItemBlocks, MakeStatus, + add_block_decls_pass_1(ItemBlocks, MakeStatus, MakeMaybeSrc, !FoundInvalidInstOrMode, !ModuleInfo, !Specs). :- pred add_item_decls_pass_1(item_status::in, list(item)::in, @@ -396,8 +425,6 @@ add_items_pass_3(Status, [Item | Items], !ModuleInfo, !QualInfo, !Specs) :- %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% - % The bool records whether any cyclic insts or modes were detected. - % :- pred add_item_decl_pass_1(item_status::in, item::in, found_invalid_inst_or_mode::in, found_invalid_inst_or_mode::out, module_info::in, module_info::out, @@ -456,22 +483,33 @@ add_item_decl_pass_1(Status, Item, %---------------------------------------------------------------------------% -:- pred add_item_avail_pass_1(import_status::in, item_avail::in, +:- type avail_locn + ---> avail_in_src(module_section) + ; avail_elsewhere(import_status). + +:- pred add_item_avail_pass_1(avail_locn::in, item_avail::in, module_info::in, module_info::out) is det. -add_item_avail_pass_1(Status, Avail, !ModuleInfo) :- - ModuleName = item_avail_module_name(Avail), - DefinedInThisModule = status_defined_in_this_module(Status), +add_item_avail_pass_1(AvailLocn, Avail, !ModuleInfo) :- ( - DefinedInThisModule = yes, - module_add_imported_module_name(Status, ModuleName, !ModuleInfo) + Avail = avail_import(avail_import_info(ModuleName, Context, _SeqNum)), + ImportOrUse = import_decl ; - DefinedInThisModule = no, + Avail = avail_use(avail_use_info(ModuleName, Context, _SeqNum)), + ImportOrUse = use_decl + ), + ( + AvailLocn = avail_in_src(Section), + module_add_avail_module_name(ModuleName, Section, ImportOrUse, + yes(Context), !ModuleInfo) + ; + AvailLocn = avail_elsewhere(Status), ( if Status = status_imported(import_locn_ancestor_private_interface_proper) then - module_add_imported_module_name(Status, ModuleName, !ModuleInfo), + module_add_avail_module_name(ModuleName, ms_implementation, + ImportOrUse, no, !ModuleInfo), % Any import_module which comes from a private interface % must by definition be a module used by the parent module. module_info_add_parent_to_used_modules(ModuleName, !ModuleInfo) @@ -712,6 +750,10 @@ add_pass_2_instance(ItemInstance, Status, !ModuleInfo, !Specs) :- Status = item_status(ImportStatus, _), ( Body = instance_body_abstract, + % XXX This can make the status abstract_imported even if the instance + % is NOT imported. + % When this is fixed, please undo the workaround for this bug + % in instance_used_modules in unused_imports.m. make_status_abstract(ImportStatus, BodyStatus) ; Body = instance_body_concrete(_), diff --git a/compiler/make_tags.m b/compiler/make_tags.m index ed942131d..1ebf8ade2 100644 --- a/compiler/make_tags.m +++ b/compiler/make_tags.m @@ -97,10 +97,6 @@ :- implementation. -:- import_module hlds.hlds_pred. -:- import_module hlds.hlds_out. -:- import_module hlds.hlds_out.hlds_out_util. -:- import_module libs.globals. :- import_module libs.options. :- import_module mdbcomp.sym_name. :- import_module parse_tree.prog_type. diff --git a/compiler/matching.m b/compiler/matching.m index 3da6b220e..37c8aef59 100644 --- a/compiler/matching.m +++ b/compiler/matching.m @@ -94,7 +94,6 @@ :- import_module pair. :- import_module queue. :- import_module require. -:- import_module string. :- import_module term. % The stack optimization graph is a bipartite graph, whose two node types diff --git a/compiler/mcsolver.m b/compiler/mcsolver.m index 86638b8f0..a99d5277c 100644 --- a/compiler/mcsolver.m +++ b/compiler/mcsolver.m @@ -125,7 +125,6 @@ :- import_module eqvclass. :- import_module io. -:- import_module list. :- import_module map. :- import_module multi_map. :- import_module require. diff --git a/compiler/mercury_compile.m b/compiler/mercury_compile.m index 3cd0fd02b..b14aed168 100644 --- a/compiler/mercury_compile.m +++ b/compiler/mercury_compile.m @@ -70,8 +70,6 @@ :- import_module parse_tree.modules. :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_event. -:- import_module parse_tree.prog_foreign. -:- import_module parse_tree.prog_io. :- import_module parse_tree.prog_io_error. :- import_module parse_tree.prog_item. :- import_module parse_tree.read_modules. @@ -91,17 +89,14 @@ :- import_module transform_hlds.intermod. :- import_module transform_hlds.trans_opt. -:- import_module assoc_list. :- import_module bool. :- import_module char. :- import_module cord. :- import_module dir. :- import_module gc. :- import_module getopt_io. -:- import_module list. :- import_module map. :- import_module maybe. -:- import_module pair. :- import_module require. :- import_module set. :- import_module string. diff --git a/compiler/mercury_compile_erl_back_end.m b/compiler/mercury_compile_erl_back_end.m index d1c683551..691f732d9 100644 --- a/compiler/mercury_compile_erl_back_end.m +++ b/compiler/mercury_compile_erl_back_end.m @@ -38,7 +38,6 @@ :- import_module backend_libs.base_typeclass_info. :- import_module backend_libs.type_class_info. :- import_module backend_libs.type_ctor_info. -:- import_module erl_backend.elds. :- import_module erl_backend.elds_to_erlang. :- import_module erl_backend.erl_code_gen. :- import_module erl_backend.erl_rtti. diff --git a/compiler/mercury_compile_front_end.m b/compiler/mercury_compile_front_end.m index c1a27fdee..3c0ad4b20 100644 --- a/compiler/mercury_compile_front_end.m +++ b/compiler/mercury_compile_front_end.m @@ -102,7 +102,6 @@ :- import_module libs.globals. :- import_module libs.options. :- import_module mdbcomp. -:- import_module mdbcomp.prim_data. :- import_module mdbcomp.sym_name. :- import_module parse_tree.file_names. :- import_module parse_tree.module_cmds. @@ -112,7 +111,6 @@ :- import_module transform_hlds.intermod. :- import_module benchmarking. -:- import_module bool. :- import_module int. :- import_module map. :- import_module maybe. @@ -638,7 +636,7 @@ maybe_warn_about_unused_imports(Verbose, Stats, !HLDS, !Specs, !IO) :- WarnUnusedImports = yes, maybe_write_out_errors(Verbose, Globals, !HLDS, !Specs, !IO), maybe_write_string(Verbose, "% Checking for unused imports...", !IO), - warn_about_unused_imports(!.HLDS, UnusedImportSpecs, !IO), + warn_about_unused_imports(!.HLDS, UnusedImportSpecs), !:Specs = UnusedImportSpecs ++ !.Specs, maybe_write_out_errors(Verbose, Globals, !HLDS, !Specs, !IO), maybe_write_string(Verbose, " done.\n", !IO), diff --git a/compiler/mercury_compile_llds_back_end.m b/compiler/mercury_compile_llds_back_end.m index aa1df8293..aa7459edd 100644 --- a/compiler/mercury_compile_llds_back_end.m +++ b/compiler/mercury_compile_llds_back_end.m @@ -47,7 +47,6 @@ :- import_module backend_libs.export. :- import_module backend_libs.foreign. :- import_module backend_libs.proc_label. -:- import_module backend_libs.rtti. :- import_module backend_libs.type_class_info. :- import_module backend_libs.type_ctor_info. :- import_module check_hlds.simplify. @@ -65,7 +64,6 @@ :- import_module ll_backend.continuation_info. :- import_module ll_backend.dupproc. :- import_module ll_backend.follow_code. -:- import_module ll_backend.global_data. :- import_module ll_backend.liveness. :- import_module ll_backend.llds_out. :- import_module ll_backend.llds_out.llds_out_file. @@ -91,7 +89,6 @@ :- import_module assoc_list. :- import_module cord. :- import_module int. -:- import_module list. :- import_module map. :- import_module maybe. :- import_module pair. diff --git a/compiler/mercury_compile_middle_passes.m b/compiler/mercury_compile_middle_passes.m index d02fa3898..3efef4394 100644 --- a/compiler/mercury_compile_middle_passes.m +++ b/compiler/mercury_compile_middle_passes.m @@ -45,7 +45,6 @@ :- import_module backend_libs.type_ctor_info. :- import_module bytecode_backend.bytecode. :- import_module bytecode_backend.bytecode_gen. -:- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. :- import_module libs.file_util. :- import_module libs.globals. diff --git a/compiler/mercury_compile_mlds_back_end.m b/compiler/mercury_compile_mlds_back_end.m index d304fbcd8..706d564da 100644 --- a/compiler/mercury_compile_mlds_back_end.m +++ b/compiler/mercury_compile_mlds_back_end.m @@ -60,7 +60,6 @@ :- import_module backend_libs.type_ctor_info. :- import_module hlds.mark_static_terms. % HLDS -> HLDS :- import_module libs.file_util. -:- import_module libs.globals. :- import_module libs.options. :- import_module ml_backend.add_trail_ops. % HLDS -> HLDS :- import_module ml_backend.add_heap_ops. % HLDS -> HLDS @@ -74,13 +73,11 @@ :- import_module ml_backend.mlds_to_cs. % MLDS -> C# :- import_module ml_backend.mlds_to_ilasm. % MLDS -> IL assembler :- import_module ml_backend.ml_util. % MLDS utility predicates -:- import_module parse_tree. :- import_module parse_tree.error_util. :- import_module parse_tree.file_names. :- import_module top_level.mercury_compile_front_end. :- import_module top_level.mercury_compile_llds_back_end. -:- import_module bool. :- import_module getopt_io. :- import_module list. :- import_module pprint. diff --git a/compiler/mercury_to_mercury.m b/compiler/mercury_to_mercury.m index e642f4a0e..f777f13e2 100644 --- a/compiler/mercury_to_mercury.m +++ b/compiler/mercury_to_mercury.m @@ -396,7 +396,7 @@ :- func mercury_quantifier_to_string(tvarset, var_name_print, existq_tvars) = string. -:- pred mercury_output_instance_methods(instance_methods::in, +:- pred mercury_output_instance_methods(list(instance_method)::in, io::di, io::uo) is det. :- pred mercury_output_trace_expr(pred(T, io, io)::in(pred(in, di, uo) is det), @@ -494,7 +494,6 @@ :- implementation. -:- import_module libs.globals. :- import_module libs.options. :- import_module libs.rat. :- import_module parse_tree.file_kind. @@ -515,9 +514,7 @@ :- import_module ops. :- import_module require. :- import_module string. -:- import_module term. :- import_module term_io. -:- import_module varset. %-----------------------------------------------------------------------------% diff --git a/compiler/middle_rec.m b/compiler/middle_rec.m index 2d99f6bc1..3d2530551 100644 --- a/compiler/middle_rec.m +++ b/compiler/middle_rec.m @@ -49,7 +49,6 @@ :- import_module maybe. :- import_module require. :- import_module set. -:- import_module string. %---------------------------------------------------------------------------% diff --git a/compiler/ml_accurate_gc.m b/compiler/ml_accurate_gc.m index 4d2932d47..4087cea2f 100644 --- a/compiler/ml_accurate_gc.m +++ b/compiler/ml_accurate_gc.m @@ -100,9 +100,7 @@ :- import_module counter. :- import_module int. :- import_module list. -:- import_module map. :- import_module maybe. -:- import_module set. %-----------------------------------------------------------------------------% % diff --git a/compiler/ml_call_gen.m b/compiler/ml_call_gen.m index 933e2c7b3..e96eb5fdf 100644 --- a/compiler/ml_call_gen.m +++ b/compiler/ml_call_gen.m @@ -97,7 +97,6 @@ :- import_module mdbcomp.prim_data. :- import_module ml_backend.ml_code_util. -:- import_module bool. :- import_module int. :- import_module maybe. :- import_module require. diff --git a/compiler/ml_code_gen.m b/compiler/ml_code_gen.m index d073f32d4..edeb3fb5b 100644 --- a/compiler/ml_code_gen.m +++ b/compiler/ml_code_gen.m @@ -520,17 +520,14 @@ :- import_module ml_backend.ml_commit_gen. :- import_module ml_backend.ml_disj_gen. :- import_module ml_backend.ml_foreign_proc_gen. -:- import_module ml_backend.ml_gen_info. :- import_module ml_backend.ml_switch_gen. :- import_module ml_backend.ml_unify_gen. -:- import_module parse_tree.prog_type. :- import_module parse_tree.set_of_var. :- import_module bool. :- import_module map. :- import_module maybe. :- import_module require. -:- import_module set. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% diff --git a/compiler/ml_code_util.m b/compiler/ml_code_util.m index e5655c752..0ccd48fce 100644 --- a/compiler/ml_code_util.m +++ b/compiler/ml_code_util.m @@ -550,7 +550,6 @@ :- import_module check_hlds.mode_util. :- import_module check_hlds.type_util. :- import_module hlds.vartypes. -:- import_module libs.globals. :- import_module libs.options. :- import_module mdbcomp.builtin_modules. :- import_module mdbcomp.program_representation. @@ -559,7 +558,6 @@ :- import_module ml_backend.ml_code_gen. :- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.java_names. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_type. :- import_module parse_tree.prog_util. diff --git a/compiler/ml_commit_gen.m b/compiler/ml_commit_gen.m index 9d1f3505b..ac9eb10ff 100644 --- a/compiler/ml_commit_gen.m +++ b/compiler/ml_commit_gen.m @@ -187,7 +187,6 @@ :- import_module bool. :- import_module map. :- import_module maybe. -:- import_module set. :- import_module string. %-----------------------------------------------------------------------------% diff --git a/compiler/ml_disj_gen.m b/compiler/ml_disj_gen.m index 18da571a3..33edb1311 100644 --- a/compiler/ml_disj_gen.m +++ b/compiler/ml_disj_gen.m @@ -128,13 +128,11 @@ :- import_module libs.options. :- import_module ml_backend.ml_code_gen. :- import_module ml_backend.ml_code_util. -:- import_module ml_backend.ml_gen_info. :- import_module ml_backend.ml_global_data. :- import_module ml_backend.ml_util. :- import_module parse_tree.set_of_var. :- import_module bool. -:- import_module map. :- import_module maybe. :- import_module require. diff --git a/compiler/ml_global_data.m b/compiler/ml_global_data.m index cdb9a84cb..a49b01c84 100644 --- a/compiler/ml_global_data.m +++ b/compiler/ml_global_data.m @@ -217,7 +217,6 @@ :- import_module bool. :- import_module int. -:- import_module maybe. :- import_module require. :- import_module string. diff --git a/compiler/ml_lookup_switch.m b/compiler/ml_lookup_switch.m index 26a7639c7..6cf10c479 100644 --- a/compiler/ml_lookup_switch.m +++ b/compiler/ml_lookup_switch.m @@ -132,7 +132,6 @@ :- import_module bool. :- import_module cord. :- import_module int. -:- import_module map. :- import_module pair. :- import_module require. diff --git a/compiler/ml_proc_gen.m b/compiler/ml_proc_gen.m index 09b9c614e..c8479ddc4 100644 --- a/compiler/ml_proc_gen.m +++ b/compiler/ml_proc_gen.m @@ -32,7 +32,6 @@ :- import_module backend_libs.rtti. :- import_module check_hlds.mode_util. :- import_module hlds.code_model. -:- import_module hlds.goal_util. :- import_module hlds.hlds_data. :- import_module hlds.hlds_goal. :- import_module hlds.hlds_pred. @@ -52,7 +51,6 @@ :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_foreign. :- import_module parse_tree.prog_type. -:- import_module parse_tree.set_of_var. :- import_module parse_tree.status. :- import_module bool. diff --git a/compiler/ml_simplify_switch.m b/compiler/ml_simplify_switch.m index 38abcdef0..e6d831bee 100644 --- a/compiler/ml_simplify_switch.m +++ b/compiler/ml_simplify_switch.m @@ -41,7 +41,6 @@ :- import_module libs.globals. :- import_module libs.options. :- import_module ml_backend.ml_code_util. -:- import_module ml_backend.ml_switch_gen. :- import_module ml_backend.ml_target_util. :- import_module parse_tree.prog_type. diff --git a/compiler/ml_switch_gen.m b/compiler/ml_switch_gen.m index 538eb6351..30d1c1456 100644 --- a/compiler/ml_switch_gen.m +++ b/compiler/ml_switch_gen.m @@ -136,7 +136,6 @@ :- import_module backend_libs.builtin_ops. :- import_module backend_libs.foreign. :- import_module backend_libs.switch_util. -:- import_module check_hlds.type_util. :- import_module hlds.hlds_data. :- import_module hlds.hlds_module. :- import_module libs.globals. @@ -149,7 +148,6 @@ :- import_module ml_backend.ml_tag_switch. :- import_module ml_backend.ml_target_util. :- import_module ml_backend.ml_unify_gen. -:- import_module parse_tree.prog_type. :- import_module assoc_list. :- import_module bool. diff --git a/compiler/ml_type_gen.m b/compiler/ml_type_gen.m index 66b0347b3..85116e4f7 100644 --- a/compiler/ml_type_gen.m +++ b/compiler/ml_type_gen.m @@ -116,17 +116,14 @@ :- implementation. :- import_module check_hlds.polymorphism. -:- import_module hlds.hlds_pred. :- import_module libs.options. :- import_module mdbcomp.builtin_modules. :- import_module ml_backend.ml_code_util. :- import_module ml_backend.ml_util. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_type. :- import_module parse_tree.status. :- import_module int. -:- import_module list. :- import_module map. :- import_module pair. :- import_module require. diff --git a/compiler/ml_unify_gen.m b/compiler/ml_unify_gen.m index 861335bfc..e501b847a 100644 --- a/compiler/ml_unify_gen.m +++ b/compiler/ml_unify_gen.m @@ -152,7 +152,6 @@ :- import_module map. :- import_module pair. :- import_module require. -:- import_module set. :- import_module term. :- import_module unit. :- import_module varset. diff --git a/compiler/mlds.m b/compiler/mlds.m index 6da86e2dc..72dc21f72 100644 --- a/compiler/mlds.m +++ b/compiler/mlds.m @@ -1853,16 +1853,11 @@ :- implementation. -:- import_module backend_libs.foreign. :- import_module check_hlds.type_util. -:- import_module hlds.hlds_data. -:- import_module libs.globals. :- import_module mdbcomp.builtin_modules. :- import_module parse_tree.file_names. :- import_module parse_tree.java_names. -:- import_module parse_tree.prog_type. -:- import_module int. :- import_module require. :- import_module string. :- import_module term. diff --git a/compiler/mlds_to_c.m b/compiler/mlds_to_c.m index 367e58f84..a65e11239 100644 --- a/compiler/mlds_to_c.m +++ b/compiler/mlds_to_c.m @@ -81,7 +81,6 @@ :- import_module parse_tree.prog_type. :- import_module assoc_list. -:- import_module bool. :- import_module cord. :- import_module float. :- import_module int. diff --git a/compiler/mlds_to_cs.m b/compiler/mlds_to_cs.m index f76cc0853..02d174cc0 100644 --- a/compiler/mlds_to_cs.m +++ b/compiler/mlds_to_cs.m @@ -62,7 +62,6 @@ :- import_module ml_backend.ml_global_data. :- import_module ml_backend.ml_type_gen. % for ml_gen_type_name :- import_module ml_backend.ml_util. -:- import_module ml_backend.mlds. :- import_module ml_backend.rtti_to_mlds. :- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.file_names. % for mercury_std_library_name. diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m index 555336303..38ea6cbee 100644 --- a/compiler/mlds_to_java.m +++ b/compiler/mlds_to_java.m @@ -100,7 +100,6 @@ :- import_module ml_backend.ml_global_data. :- import_module ml_backend.ml_type_gen. % for ml_gen_type_name :- import_module ml_backend.ml_util. -:- import_module ml_backend.mlds. :- import_module ml_backend.rtti_to_mlds. :- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.file_names. % for mercury_std_library_name. diff --git a/compiler/mode_constraint_robdd.m b/compiler/mode_constraint_robdd.m index 3c4355f95..e3d8bfb10 100644 --- a/compiler/mode_constraint_robdd.m +++ b/compiler/mode_constraint_robdd.m @@ -159,16 +159,11 @@ % :- import_module mode_robdd.check. :- import_module bimap. -:- import_module bool. :- import_module list. -:- import_module map. :- import_module require. -:- import_module robdd. :- import_module solutions. :- import_module sparse_bitset. -:- import_module stack. :- import_module std_util. -:- import_module term. :- import_module varset. :- type mc_type diff --git a/compiler/mode_constraints.m b/compiler/mode_constraints.m index c5dc054eb..cee82b181 100644 --- a/compiler/mode_constraints.m +++ b/compiler/mode_constraints.m @@ -75,7 +75,6 @@ :- import_module parse_tree. :- import_module parse_tree.file_names. :- import_module parse_tree.prog_data. -:- import_module parse_tree.prog_detism. :- import_module parse_tree.prog_mode. :- import_module parse_tree.set_of_var. :- import_module transform_hlds.dependency_graph. diff --git a/compiler/mode_debug.m b/compiler/mode_debug.m index e48306ba3..66a79b68c 100644 --- a/compiler/mode_debug.m +++ b/compiler/mode_debug.m @@ -39,7 +39,6 @@ :- import_module hlds. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_mode. -:- import_module hlds.hlds_out.hlds_out_util. :- import_module hlds.instmap. :- import_module parse_tree. :- import_module parse_tree.mercury_to_mercury. diff --git a/compiler/mode_errors.m b/compiler/mode_errors.m index 3068f3e33..f700fd4f4 100644 --- a/compiler/mode_errors.m +++ b/compiler/mode_errors.m @@ -241,7 +241,6 @@ :- implementation. -:- import_module check_hlds.mode_info. :- import_module check_hlds.mode_util. :- import_module hlds.hlds_error_util. :- import_module hlds.hlds_out. diff --git a/compiler/mode_info.m b/compiler/mode_info.m index 06e70ea71..6b4c8f486 100644 --- a/compiler/mode_info.m +++ b/compiler/mode_info.m @@ -350,14 +350,12 @@ :- implementation. -:- import_module check_hlds.delay_info. -:- import_module check_hlds.mode_errors. :- import_module libs. -:- import_module map. :- import_module libs.globals. :- import_module libs.options. :- import_module int. +:- import_module map. :- import_module pair. :- import_module require. :- import_module term. diff --git a/compiler/mode_ordering.m b/compiler/mode_ordering.m index 5917e2f0d..ed67e401a 100644 --- a/compiler/mode_ordering.m +++ b/compiler/mode_ordering.m @@ -44,7 +44,6 @@ :- implementation. :- import_module check_hlds.clause_to_proc. -:- import_module check_hlds.mode_constraint_robdd. :- import_module hlds.hlds_goal. :- import_module hlds.inst_graph. :- import_module mode_robdd. @@ -61,7 +60,6 @@ :- import_module digraph. :- import_module pair. :- import_module require. -:- import_module set. :- import_module solutions. :- import_module stack. diff --git a/compiler/mode_robdd.implications.m b/compiler/mode_robdd.implications.m index a9e02fbb4..c899c46cf 100644 --- a/compiler/mode_robdd.implications.m +++ b/compiler/mode_robdd.implications.m @@ -72,7 +72,6 @@ :- import_module map. :- import_module pair. :- import_module sparse_bitset. -:- import_module term. % Uncomment these for debugging. % :- import_module unsafe, io. diff --git a/compiler/mode_robdd.tfeirn.m b/compiler/mode_robdd.tfeirn.m index 3fdee0dda..c57a87376 100644 --- a/compiler/mode_robdd.tfeirn.m +++ b/compiler/mode_robdd.tfeirn.m @@ -200,7 +200,6 @@ :- import_module int. :- import_module list. :- import_module map. -:- import_module robdd. :- import_module sparse_bitset. % T - true vars, F - False Vars, E - equivalent vars, N - diff --git a/compiler/mode_util.m b/compiler/mode_util.m index 1da39c5dd..544843a27 100644 --- a/compiler/mode_util.m +++ b/compiler/mode_util.m @@ -217,7 +217,6 @@ :- import_module mdbcomp.builtin_modules. :- import_module mdbcomp.prim_data. :- import_module mdbcomp.sym_name. -:- import_module parse_tree.prog_detism. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_type. :- import_module parse_tree.prog_type_subst. @@ -229,7 +228,6 @@ :- import_module pair. :- import_module require. :- import_module set. -:- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/modecheck_call.m b/compiler/modecheck_call.m index ec6d8476f..a5e9c5275 100644 --- a/compiler/modecheck_call.m +++ b/compiler/modecheck_call.m @@ -81,13 +81,10 @@ :- import_module check_hlds.inst_match. :- import_module check_hlds.inst_util. :- import_module check_hlds.mode_errors. -:- import_module check_hlds.mode_info. :- import_module check_hlds.mode_util. -:- import_module check_hlds.modecheck_util. :- import_module check_hlds.unify_proc. :- import_module hlds.instmap. :- import_module hlds.vartypes. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_detism. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_type. diff --git a/compiler/modecheck_conj.m b/compiler/modecheck_conj.m index f9a1c3155..ab5d233b6 100644 --- a/compiler/modecheck_conj.m +++ b/compiler/modecheck_conj.m @@ -48,12 +48,10 @@ :- import_module assoc_list. :- import_module bool. :- import_module int. -:- import_module list. :- import_module map. :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% diff --git a/compiler/modecheck_goal.m b/compiler/modecheck_goal.m index 45304a554..098b9c17c 100644 --- a/compiler/modecheck_goal.m +++ b/compiler/modecheck_goal.m @@ -148,13 +148,11 @@ :- import_module parse_tree.set_of_var. :- import_module bag. -:- import_module bool. :- import_module list. :- import_module map. :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module std_util. :- import_module string. :- import_module term. diff --git a/compiler/modecheck_unify.m b/compiler/modecheck_unify.m index 5d3a69682..eb24d7b69 100644 --- a/compiler/modecheck_unify.m +++ b/compiler/modecheck_unify.m @@ -47,7 +47,6 @@ :- import_module check_hlds.inst_util. :- import_module check_hlds.mode_debug. :- import_module check_hlds.mode_errors. -:- import_module check_hlds.mode_info. :- import_module check_hlds.mode_util. :- import_module check_hlds.modecheck_goal. :- import_module check_hlds.modecheck_util. @@ -58,7 +57,6 @@ :- import_module check_hlds.unique_modes. :- import_module hlds.const_struct. :- import_module hlds.goal_util. -:- import_module hlds.hlds_goal. :- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. :- import_module hlds.instmap. @@ -83,7 +81,6 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/modecheck_util.m b/compiler/modecheck_util.m index f615f48e7..ef75c6d9f 100644 --- a/compiler/modecheck_util.m +++ b/compiler/modecheck_util.m @@ -209,7 +209,6 @@ :- import_module bool. :- import_module int. -:- import_module list. :- import_module map. :- import_module pair. :- import_module require. diff --git a/compiler/modes.m b/compiler/modes.m index 863d46f5e..37d71ad84 100644 --- a/compiler/modes.m +++ b/compiler/modes.m @@ -167,7 +167,6 @@ :- import_module bag. :- import_module int. :- import_module io. -:- import_module list. :- import_module map. :- import_module maybe. :- import_module queue. diff --git a/compiler/module_deps_graph.m b/compiler/module_deps_graph.m index 402977de8..7c76f5207 100644 --- a/compiler/module_deps_graph.m +++ b/compiler/module_deps_graph.m @@ -40,20 +40,7 @@ :- implementation. -:- import_module libs.file_util. -:- import_module libs.options. -:- import_module parse_tree.deps_map. -:- import_module parse_tree.file_names. -:- import_module parse_tree.prog_io_error. -:- import_module parse_tree.prog_out. - -:- import_module bool. -:- import_module list. -:- import_module map. -:- import_module pair. :- import_module set. -:- import_module sparse_bitset. -:- import_module string. :- type deps_graph_key == digraph_key(module_name). diff --git a/compiler/module_imports.m b/compiler/module_imports.m index 50cd0c825..5347e8b95 100644 --- a/compiler/module_imports.m +++ b/compiler/module_imports.m @@ -231,7 +231,6 @@ :- import_module mdbcomp.prim_data. :- import_module parse_tree.comp_unit_interface. :- import_module parse_tree.get_dependencies. -:- import_module parse_tree.modules. % undesirable dependency :- import_module dir. :- import_module term. diff --git a/compiler/module_qual.m b/compiler/module_qual.m index 83766b742..bd78a9191 100644 --- a/compiler/module_qual.m +++ b/compiler/module_qual.m @@ -58,6 +58,16 @@ % cannot implement any equivalent of --warn-interface-imports that would % report unnecessary imports in the *implementation* section of a module. % +% If the --warn-unused-imports option is set, then unused_imports.m +% can generate all the warnings we would, but it can generate *better* +% messages, since unlike the code here, it can report that an imported module +% is unused *anywhere* in the module. However, even if --warn-unused-imports +% *is* set, the code in unused_imports.m won't be invoked if we stop +% compilation before its normal invocation time, due to e.g. type or more +% errors. What we should do is generate warnings here; print them if we +% stop before the unused_imports pass; throw them away if we *do* get to +% that pass. We don't (yet) do this. +% %-----------------------------------------------------------------------------% :- module parse_tree.module_qual. @@ -255,7 +265,6 @@ module_qualify_aug_comp_unit(Globals, AugCompUnit0, AugCompUnit, % imported module that exports a type class instance is used in % the interface of the importing module, except if the importing % module itself exports _no_ type class instances. - % mq_info_get_as_yet_unused_interface_modules(!.Info, UnusedImportsMap0), mq_info_get_exported_instances_flag(!.Info, ModuleExportsInstances), ( diff --git a/compiler/modules.m b/compiler/modules.m index 58b832ee5..cc160a4fa 100644 --- a/compiler/modules.m +++ b/compiler/modules.m @@ -1131,6 +1131,10 @@ check_imports_accessibility(AugCompUnit, ImportedModules, IntItemBlocks = DirectIntItemBlocks ++ IndirectIntItemBlocks, record_includes_imports_uses(SrcItemBlocks, IntItemBlocks, OptItemBlocks, IntForOptItemBlocks, InclMap, ImportUseMap), + % XXX ITEM_LIST We should either record in an updated AugCompUnit + % the set of imported modules that are inaccessible, or remove their + % imports from it, so that we don't generate "unused module" warnings + % for them when --warn-unused-imports is enabled. set.foldl(check_module_accessibility(ModuleName, InclMap, ImportUseMap), ImportedModules, !Specs). @@ -1276,12 +1280,6 @@ record_avails_acc([Avail | Avails], !ImportUseMap) :- % InclMap tells us what modules are accessible, and ImportUseMap tells % the location(s) where each imported module is imported (or used). % - % XXX ITEM_LIST We should also be able to report duplicate imports, - % duplicate uses, and modules that are both imported and used. - % For generating good error messages about such problems, we would - % probably need to record, for each import or use, not just the context, - % but also the section in which that import or use occurred. - % :- pred check_module_accessibility(module_name::in, module_inclusion_map::in, module_import_or_use_map::in, module_name::in, list(error_spec)::in, list(error_spec)::out) is det. diff --git a/compiler/par_conj_gen.m b/compiler/par_conj_gen.m index 305945aa5..d910d5eac 100644 --- a/compiler/par_conj_gen.m +++ b/compiler/par_conj_gen.m @@ -128,31 +128,25 @@ :- import_module check_hlds.mode_util. :- import_module hlds.hlds_llds. :- import_module hlds.hlds_module. -:- import_module hlds.hlds_pred. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_util. :- import_module hlds.instmap. :- import_module libs.globals. :- import_module libs.options. :- import_module ll_backend.code_gen. -:- import_module ll_backend.code_info. :- import_module ll_backend.code_util. :- import_module ll_backend.continuation_info. :- import_module ll_backend.exprn_aux. :- import_module ll_backend.llds_out. :- import_module ll_backend.llds_out.llds_out_data. -:- import_module ll_backend.var_locn. :- import_module mdbcomp.goal_path. :- import_module parse_tree.set_of_var. -:- import_module assoc_list. :- import_module bool. :- import_module cord. :- import_module int. -:- import_module list. :- import_module map. :- import_module maybe. -:- import_module pair. :- import_module require. :- import_module set. :- import_module string. diff --git a/compiler/parallel_to_plain_conj.m b/compiler/parallel_to_plain_conj.m index 787cfd0f4..76b758208 100644 --- a/compiler/parallel_to_plain_conj.m +++ b/compiler/parallel_to_plain_conj.m @@ -34,7 +34,6 @@ :- import_module hlds.hlds_goal. -:- import_module bool. :- import_module io. :- import_module list. :- import_module require. diff --git a/compiler/parse_string_format.m b/compiler/parse_string_format.m index 09e75e9e2..2f28565a0 100644 --- a/compiler/parse_string_format.m +++ b/compiler/parse_string_format.m @@ -24,6 +24,7 @@ :- import_module parse_tree.prog_data. :- import_module string.parse_util. +:- import_module char. :- import_module list. %---------------------------------------------------------------------------% @@ -103,9 +104,7 @@ :- implementation. :- import_module bool. -:- import_module float. :- import_module int. -:- import_module integer. :- import_module maybe. :- import_module require. diff --git a/compiler/pd_debug.m b/compiler/pd_debug.m index 9ce61a05d..fdbc33231 100644 --- a/compiler/pd_debug.m +++ b/compiler/pd_debug.m @@ -65,12 +65,10 @@ :- import_module hlds.hlds_out.hlds_out_mode. :- import_module hlds.hlds_out.hlds_out_util. :- import_module hlds.instmap. -:- import_module hlds.instmap. :- import_module libs.globals. :- import_module libs.options. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_out. -:- import_module parse_tree.set_of_var. :- import_module set. diff --git a/compiler/pd_info.m b/compiler/pd_info.m index ee269ad5b..0b23d9bfd 100644 --- a/compiler/pd_info.m +++ b/compiler/pd_info.m @@ -118,17 +118,13 @@ :- import_module check_hlds.inst_match. :- import_module check_hlds.modecheck_util. -:- import_module hlds.hlds_goal. -:- import_module hlds.hlds_pred. :- import_module hlds.vartypes. :- import_module mdbcomp.prim_data. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_util. :- import_module parse_tree.set_of_var. :- import_module transform_hlds.pd_debug. :- import_module transform_hlds.pd_util. -:- import_module bool. :- import_module int. :- import_module require. :- import_module term. diff --git a/compiler/pd_term.m b/compiler/pd_term.m index ac06d9863..a4997abe2 100644 --- a/compiler/pd_term.m +++ b/compiler/pd_term.m @@ -102,7 +102,6 @@ :- implementation. -:- import_module hlds.hlds_pred. :- import_module parse_tree.prog_data. :- import_module transform_hlds.pd_util. diff --git a/compiler/pd_util.m b/compiler/pd_util.m index 16d474190..22a9b3b22 100644 --- a/compiler/pd_util.m +++ b/compiler/pd_util.m @@ -172,7 +172,6 @@ :- import_module libs.options. :- import_module parse_tree.error_util. :- import_module parse_tree.prog_type. -:- import_module parse_tree.set_of_var. :- import_module transform_hlds.constraint. :- import_module transform_hlds.pd_debug. diff --git a/compiler/pickle.m b/compiler/pickle.m index 5e09347f0..092cb9ca1 100644 --- a/compiler/pickle.m +++ b/compiler/pickle.m @@ -101,7 +101,6 @@ :- import_module deconstruct. :- import_module exception. :- import_module int. -:- import_module io. :- import_module list. :- import_module map. :- import_module require. diff --git a/compiler/polymorphism.m b/compiler/polymorphism.m index 7688b0ac1..760c32f0f 100644 --- a/compiler/polymorphism.m +++ b/compiler/polymorphism.m @@ -382,7 +382,6 @@ :- implementation. :- import_module check_hlds.clause_to_proc. -:- import_module check_hlds.mode_util. :- import_module check_hlds.type_util. :- import_module hlds.from_ground_term_util. :- import_module hlds.const_struct. @@ -420,7 +419,6 @@ :- import_module set. :- import_module solutions. :- import_module string. -:- import_module term. :- import_module varset. %-----------------------------------------------------------------------------% diff --git a/compiler/post_term_analysis.m b/compiler/post_term_analysis.m index 6c3b9c2bd..1e060b45a 100644 --- a/compiler/post_term_analysis.m +++ b/compiler/post_term_analysis.m @@ -38,9 +38,6 @@ :- import_module hlds.goal_form. :- import_module hlds.goal_util. :- import_module hlds.hlds_data. -:- import_module hlds.hlds_module. -:- import_module hlds.hlds_out. -:- import_module hlds.hlds_out.hlds_out_util. :- import_module hlds.hlds_pred. :- import_module hlds.special_pred. :- import_module libs.globals. diff --git a/compiler/post_typecheck.m b/compiler/post_typecheck.m index 8e4a7b8f9..208c18e1b 100644 --- a/compiler/post_typecheck.m +++ b/compiler/post_typecheck.m @@ -147,7 +147,6 @@ :- import_module mdbcomp.prim_data. :- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.mercury_to_mercury. -:- import_module parse_tree.prog_out. :- import_module parse_tree.prog_type. :- import_module parse_tree.prog_type_subst. :- import_module parse_tree.prog_util. diff --git a/compiler/pragma_c_gen.m b/compiler/pragma_c_gen.m index 88e1b8b58..d664af0e0 100644 --- a/compiler/pragma_c_gen.m +++ b/compiler/pragma_c_gen.m @@ -65,7 +65,6 @@ :- import_module hlds.hlds_data. :- import_module hlds.hlds_llds. :- import_module hlds.hlds_module. -:- import_module hlds.hlds_pred. :- import_module hlds.instmap. :- import_module libs.globals. :- import_module libs.options. diff --git a/compiler/proc_label.m b/compiler/proc_label.m index f5204e4b9..d88cd5ea1 100644 --- a/compiler/proc_label.m +++ b/compiler/proc_label.m @@ -51,7 +51,6 @@ :- import_module parse_tree.prog_type. :- import_module bool. -:- import_module list. :- import_module pair. :- import_module require. :- import_module string. diff --git a/compiler/prog_ctgc.m b/compiler/prog_ctgc.m index 963f5cac2..ec36061b7 100644 --- a/compiler/prog_ctgc.m +++ b/compiler/prog_ctgc.m @@ -184,7 +184,6 @@ :- import_module require. :- import_module set. :- import_module string. -:- import_module varset. %-----------------------------------------------------------------------------% % diff --git a/compiler/prog_data.m b/compiler/prog_data.m index 20506b87d..df87709dd 100644 --- a/compiler/prog_data.m +++ b/compiler/prog_data.m @@ -50,7 +50,6 @@ :- import_module libs.options. :- import_module require. -:- import_module string. %---------------------------------------------------------------------------% % @@ -862,9 +861,7 @@ default_export_enum_attributes = :- type instance_body ---> instance_body_abstract - ; instance_body_concrete(instance_methods). - -:- type instance_methods == list(instance_method). + ; instance_body_concrete(list(instance_method)). :- func prog_constraint_get_class(prog_constraint) = class_name. :- func prog_constraint_get_arg_types(prog_constraint) = list(mer_type). diff --git a/compiler/prog_io.m b/compiler/prog_io.m index ae13cf7fc..7b6aa4382 100644 --- a/compiler/prog_io.m +++ b/compiler/prog_io.m @@ -177,7 +177,6 @@ :- implementation. :- import_module libs.options. -:- import_module parse_tree.prog_item. :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_io_item. :- import_module parse_tree.prog_io_sym_name. @@ -193,7 +192,6 @@ :- import_module parser. :- import_module require. :- import_module set. -:- import_module string. :- import_module term. :- import_module term_io. :- import_module varset. diff --git a/compiler/prog_io_dcg.m b/compiler/prog_io_dcg.m index 34aeb3a69..5ec7052dc 100644 --- a/compiler/prog_io_dcg.m +++ b/compiler/prog_io_dcg.m @@ -52,10 +52,8 @@ :- import_module parse_tree.prog_io_goal. :- import_module parse_tree.prog_io_sym_name. :- import_module parse_tree.prog_util. -:- import_module parse_tree.prog_out. :- import_module counter. -:- import_module pair. :- import_module string. %-----------------------------------------------------------------------------% diff --git a/compiler/prog_io_goal.m b/compiler/prog_io_goal.m index a40121fcc..6ae344bc0 100644 --- a/compiler/prog_io_goal.m +++ b/compiler/prog_io_goal.m @@ -112,7 +112,6 @@ :- import_module mdbcomp.sym_name. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_io_sym_name. -:- import_module parse_tree.prog_io_util. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_out. @@ -122,7 +121,6 @@ :- import_module pair. :- import_module solutions. :- import_module string. -:- import_module term. :- import_module varset. %-----------------------------------------------------------------------------% diff --git a/compiler/prog_io_item.m b/compiler/prog_io_item.m index 7f3e74972..72c3fe671 100644 --- a/compiler/prog_io_item.m +++ b/compiler/prog_io_item.m @@ -105,12 +105,9 @@ :- import_module parse_tree.prog_io_sym_name. :- import_module parse_tree.prog_io_type_defn. :- import_module parse_tree.prog_io_typeclass. -:- import_module parse_tree.prog_io_util. -:- import_module parse_tree.prog_item. :- import_module parse_tree.prog_mode. :- import_module recompilation.version. -:- import_module bool. :- import_module int. :- import_module map. :- import_module maybe. diff --git a/compiler/prog_io_mutable.m b/compiler/prog_io_mutable.m index 6f3fb2f55..90d4ec42b 100644 --- a/compiler/prog_io_mutable.m +++ b/compiler/prog_io_mutable.m @@ -45,7 +45,6 @@ :- import_module parse_tree.prog_io_pragma. :- import_module parse_tree.prog_io_sym_name. -:- import_module bool. :- import_module pair. %-----------------------------------------------------------------------------e diff --git a/compiler/prog_io_pragma.m b/compiler/prog_io_pragma.m index f8b4f128c..46414d5cf 100644 --- a/compiler/prog_io_pragma.m +++ b/compiler/prog_io_pragma.m @@ -46,7 +46,6 @@ :- import_module libs.rat. :- import_module mdbcomp.prim_data. :- import_module parse_tree.error_util. -:- import_module parse_tree.file_names. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_ctgc. :- import_module parse_tree.prog_io_type_defn. diff --git a/compiler/prog_io_typeclass.m b/compiler/prog_io_typeclass.m index 3f894e122..570121d9f 100644 --- a/compiler/prog_io_typeclass.m +++ b/compiler/prog_io_typeclass.m @@ -66,11 +66,8 @@ :- import_module parse_tree.prog_type. :- import_module parse_tree.prog_util. -:- import_module bool. :- import_module map. :- import_module require. -:- import_module term. -:- import_module varset. %-----------------------------------------------------------------------------% @@ -814,7 +811,7 @@ check_tvars_in_instance_constraint(ok1(ItemInstance), InstanceTerm, Result) :- ). :- pred parse_instance_methods(module_name::in, term::in, varset::in, - maybe1(instance_methods)::out) is det. + maybe1(list(instance_method))::out) is det. parse_instance_methods(ModuleName, MethodsTerm, VarSet, Result) :- ( if list_term_to_term_list(MethodsTerm, MethodList) then diff --git a/compiler/prog_io_util.m b/compiler/prog_io_util.m index 98e91a637..00d456ca0 100644 --- a/compiler/prog_io_util.m +++ b/compiler/prog_io_util.m @@ -235,7 +235,6 @@ :- import_module bool. :- import_module require. :- import_module set. -:- import_module term. %-----------------------------------------------------------------------------% diff --git a/compiler/prog_item.m b/compiler/prog_item.m index fd99d405b..286221fc4 100644 --- a/compiler/prog_item.m +++ b/compiler/prog_item.m @@ -520,6 +520,10 @@ ---> import_decl ; use_decl. + % Return "import_module" or "use_module", depending on the argument. + % +:- func import_or_use_decl_name(import_or_use) = string. + % The representation of an `:- import_module' or an `:- % use_module' % declaration is a list of one or more item_import_uses, each of which % makes available to the current module the entities in the interface @@ -1192,7 +1196,6 @@ :- import_module parse_tree.prog_foreign. -:- import_module cord. :- import_module map. :- import_module require. @@ -1345,6 +1348,9 @@ avail_import_info_module_name(AvailImportInfo) = ModuleName :- avail_use_info_module_name(AvailUseInfo) = ModuleName :- AvailUseInfo = avail_use_info(ModuleName, _, _). +import_or_use_decl_name(import_decl) = "import_module". +import_or_use_decl_name(use_decl) = "use_module". + %-----------------------------------------------------------------------------% % % Mutable variables. diff --git a/compiler/prog_rep.m b/compiler/prog_rep.m index 1015829fc..b3424e2cf 100644 --- a/compiler/prog_rep.m +++ b/compiler/prog_rep.m @@ -104,7 +104,6 @@ :- import_module int. :- import_module maybe. :- import_module require. -:- import_module set. :- import_module std_util. :- import_module string. :- import_module term. diff --git a/compiler/prog_util.m b/compiler/prog_util.m index d97958aec..e6f896a10 100644 --- a/compiler/prog_util.m +++ b/compiler/prog_util.m @@ -216,14 +216,11 @@ :- import_module parse_tree.prog_out. :- import_module bool. -:- import_module char. :- import_module int. :- import_module map. :- import_module pair. :- import_module require. :- import_module string. -:- import_module term_io. -:- import_module varset. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% diff --git a/compiler/purity.m b/compiler/purity.m index bf11de583..5ef4d1745 100644 --- a/compiler/purity.m +++ b/compiler/purity.m @@ -184,20 +184,15 @@ :- import_module mdbcomp.sym_name. :- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.mercury_to_mercury. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_out. :- import_module parse_tree.prog_type. :- import_module parse_tree.set_of_var. :- import_module assoc_list. -:- import_module bool. -:- import_module list. :- import_module map. -:- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/push_goals_together.m b/compiler/push_goals_together.m index 567f176f0..08c8fa632 100644 --- a/compiler/push_goals_together.m +++ b/compiler/push_goals_together.m @@ -55,20 +55,15 @@ :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_goal. :- import_module hlds.hlds_out.hlds_out_util. -:- import_module hlds.hlds_pred. :- import_module hlds.hlds_rtti. :- import_module hlds.quantification. -:- import_module mdbcomp.feedback. -:- import_module mdbcomp.feedback.automatic_parallelism. :- import_module mdbcomp.goal_path. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_data. :- import_module assoc_list. -:- import_module bool. :- import_module int. :- import_module io. -:- import_module list. :- import_module map. :- import_module pair. :- import_module require. diff --git a/compiler/quantification.m b/compiler/quantification.m index 90b3e3f0b..661c55de7 100644 --- a/compiler/quantification.m +++ b/compiler/quantification.m @@ -121,7 +121,6 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/rbmm.add_rbmm_goal_infos.m b/compiler/rbmm.add_rbmm_goal_infos.m index 3024310b4..bf22dbe85 100644 --- a/compiler/rbmm.add_rbmm_goal_infos.m +++ b/compiler/rbmm.add_rbmm_goal_infos.m @@ -66,7 +66,6 @@ :- import_module mdbcomp. :- import_module mdbcomp.builtin_modules. :- import_module parse_tree. -:- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.prog_data. :- import_module parse_tree.set_of_var. :- import_module transform_hlds.rbmm.points_to_graph. @@ -78,7 +77,6 @@ :- import_module maybe. :- import_module require. :- import_module set. -:- import_module string. %-----------------------------------------------------------------------------% % diff --git a/compiler/rbmm.condition_renaming.m b/compiler/rbmm.condition_renaming.m index 0f5b47563..55404efa8 100644 --- a/compiler/rbmm.condition_renaming.m +++ b/compiler/rbmm.condition_renaming.m @@ -146,7 +146,6 @@ :- import_module list. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. %-----------------------------------------------------------------------------% diff --git a/compiler/rbmm.execution_path.m b/compiler/rbmm.execution_path.m index 27dd5ae40..7335f0c99 100644 --- a/compiler/rbmm.execution_path.m +++ b/compiler/rbmm.execution_path.m @@ -40,7 +40,6 @@ :- import_module pair. :- import_module require. -:- import_module string. :- import_module list. :- import_module map. diff --git a/compiler/rbmm.region_instruction.m b/compiler/rbmm.region_instruction.m index e3aadd9e2..9866d871b 100644 --- a/compiler/rbmm.region_instruction.m +++ b/compiler/rbmm.region_instruction.m @@ -114,7 +114,6 @@ :- import_module pair. :- import_module require. :- import_module set. -:- import_module string. introduce_region_instructions(ModuleInfo, RptaInfoTable, ExecPathTable, LRBeforeTable, LRAfterTable, VoidVarRegionTable, BornRTable, diff --git a/compiler/rbmm.region_transformation.m b/compiler/rbmm.region_transformation.m index a2717de08..061703a20 100644 --- a/compiler/rbmm.region_transformation.m +++ b/compiler/rbmm.region_transformation.m @@ -96,8 +96,6 @@ :- import_module list. :- import_module pair. :- import_module require. -:- import_module set. -:- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/read_modules.m b/compiler/read_modules.m index f66cef5c1..d95dcb3c9 100644 --- a/compiler/read_modules.m +++ b/compiler/read_modules.m @@ -219,9 +219,7 @@ :- implementation. -:- import_module libs.globals. :- import_module libs.options. -:- import_module parse_tree.error_util. :- import_module parse_tree.prog_io. :- import_module parse_tree.prog_io_find. diff --git a/compiler/recompilation.usage.m b/compiler/recompilation.usage.m index 1a7f70c44..75b09fbf3 100644 --- a/compiler/recompilation.usage.m +++ b/compiler/recompilation.usage.m @@ -85,7 +85,6 @@ :- implementation. :- import_module hlds.hlds_data. -:- import_module hlds.hlds_pred. :- import_module hlds.passes_aux. :- import_module hlds.pred_table. :- import_module libs.file_util. @@ -96,7 +95,6 @@ :- import_module parse_tree.file_kind. :- import_module parse_tree.file_names. :- import_module parse_tree.mercury_to_mercury. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_item. :- import_module parse_tree.prog_out. :- import_module parse_tree.prog_type. @@ -104,13 +102,11 @@ :- import_module parse_tree.status. :- import_module recompilation.version. -:- import_module assoc_list. :- import_module bool. :- import_module int. :- import_module list. :- import_module queue. :- import_module require. -:- import_module solutions. :- import_module string. write_usage_file(ModuleInfo, NestedSubModules, MaybeTimestampMap, !IO) :- diff --git a/compiler/recompilation.version.m b/compiler/recompilation.version.m index 86066a805..22f57fbc0 100644 --- a/compiler/recompilation.version.m +++ b/compiler/recompilation.version.m @@ -48,7 +48,6 @@ :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_mode. -:- import_module hlds.hlds_out.hlds_out_util. :- import_module parse_tree.error_util. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_io_sym_name. diff --git a/compiler/rtti.m b/compiler/rtti.m index c5e29fc3d..f286e1b21 100644 --- a/compiler/rtti.m +++ b/compiler/rtti.m @@ -963,7 +963,6 @@ :- import_module backend_libs.name_mangle. :- import_module mdbcomp.builtin_modules. -:- import_module hlds.hlds_data. :- import_module parse_tree.prog_foreign. :- import_module parse_tree.prog_type. diff --git a/compiler/rtti_to_mlds.m b/compiler/rtti_to_mlds.m index 7f6b89ccd..c58aed06e 100644 --- a/compiler/rtti_to_mlds.m +++ b/compiler/rtti_to_mlds.m @@ -70,7 +70,6 @@ :- import_module counter. :- import_module digraph. :- import_module int. -:- import_module list. :- import_module map. :- import_module maybe. :- import_module pair. diff --git a/compiler/simplify_goal_disj.m b/compiler/simplify_goal_disj.m index a6e83fb82..7855e7713 100644 --- a/compiler/simplify_goal_disj.m +++ b/compiler/simplify_goal_disj.m @@ -57,7 +57,6 @@ :- import_module libs.options. :- import_module parse_tree.error_util. :- import_module parse_tree.prog_detism. -:- import_module parse_tree.prog_out. :- import_module parse_tree.set_of_var. :- import_module bool. diff --git a/compiler/simplify_goal_switch.m b/compiler/simplify_goal_switch.m index cdc7c061a..c78ee0107 100644 --- a/compiler/simplify_goal_switch.m +++ b/compiler/simplify_goal_switch.m @@ -50,7 +50,6 @@ :- import_module transform_hlds. :- import_module transform_hlds.pd_cost. -:- import_module bool. :- import_module list. :- import_module maybe. :- import_module pair. diff --git a/compiler/simplify_info.m b/compiler/simplify_info.m index 12eff5a11..bd90f5d50 100644 --- a/compiler/simplify_info.m +++ b/compiler/simplify_info.m @@ -192,11 +192,9 @@ :- import_module libs. :- import_module libs.globals. :- import_module libs.options. -:- import_module parse_tree.prog_type_subst. :- import_module int. :- import_module map. -:- import_module require. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% diff --git a/compiler/simplify_proc.m b/compiler/simplify_proc.m index 9b0574cbc..f8970113f 100644 --- a/compiler/simplify_proc.m +++ b/compiler/simplify_proc.m @@ -102,7 +102,6 @@ :- import_module libs. :- import_module libs.globals. :- import_module libs.options. -:- import_module libs.trace_params. :- import_module parse_tree.status. :- import_module bool. diff --git a/compiler/ssdebug.m b/compiler/ssdebug.m index a9ca71b1c..86d21c594 100644 --- a/compiler/ssdebug.m +++ b/compiler/ssdebug.m @@ -213,7 +213,6 @@ :- import_module hlds.vartypes. :- import_module libs. :- import_module libs.globals. -:- import_module libs.trace_params. :- import_module mdbcomp.builtin_modules. :- import_module mdbcomp.prim_data. :- import_module mdbcomp.sym_name. @@ -226,7 +225,6 @@ :- import_module parse_tree.status. :- import_module int. -:- import_module io. :- import_module list. :- import_module map. :- import_module maybe. diff --git a/compiler/stack_alloc.m b/compiler/stack_alloc.m index 95df9f960..6c5b682c9 100644 --- a/compiler/stack_alloc.m +++ b/compiler/stack_alloc.m @@ -40,7 +40,6 @@ :- import_module check_hlds.type_util. :- import_module hlds.code_model. -:- import_module hlds.hlds_goal. :- import_module hlds.hlds_llds. :- import_module hlds.vartypes. :- import_module libs.globals. diff --git a/compiler/stack_layout.m b/compiler/stack_layout.m index 7cad0a52a..f420fba47 100644 --- a/compiler/stack_layout.m +++ b/compiler/stack_layout.m @@ -96,20 +96,17 @@ :- implementation. -:- import_module backend_libs.bytecode_data. :- import_module backend_libs.proc_label. :- import_module backend_libs.rtti. :- import_module check_hlds.type_util. :- import_module hlds.code_model. :- import_module hlds.goal_util. :- import_module hlds.hlds_llds. -:- import_module hlds.hlds_pred. :- import_module hlds.hlds_rtti. :- import_module hlds.vartypes. :- import_module libs.globals. :- import_module libs.options. :- import_module libs.trace_params. -:- import_module ll_backend.layout. :- import_module ll_backend.layout_out. :- import_module ll_backend.ll_pseudo_type_info. :- import_module ll_backend.prog_rep_tables. @@ -120,15 +117,12 @@ :- import_module parse_tree.set_of_var. :- import_module bool. -:- import_module char. :- import_module cord. :- import_module counter. :- import_module int. -:- import_module map. :- import_module pair. :- import_module require. :- import_module set. -:- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/state_var.m b/compiler/state_var.m index ddac747f7..918179181 100644 --- a/compiler/state_var.m +++ b/compiler/state_var.m @@ -294,9 +294,8 @@ :- import_module parse_tree.prog_util. :- import_module assoc_list. -:- import_module char. +:- import_module bool. :- import_module counter. -:- import_module int. :- import_module io. :- import_module pair. :- import_module require. diff --git a/compiler/status.m b/compiler/status.m index e8ff57d23..0edac2824 100644 --- a/compiler/status.m +++ b/compiler/status.m @@ -238,8 +238,6 @@ :- implementation. -:- import_module require. - status_is_exported(status_imported(_)) = no. status_is_exported(status_external(_)) = no. status_is_exported(status_abstract_imported) = no. diff --git a/compiler/stm_expand.m b/compiler/stm_expand.m index 5e8137b88..0a85a10c8 100644 --- a/compiler/stm_expand.m +++ b/compiler/stm_expand.m @@ -172,7 +172,6 @@ :- import_module hlds.goal_util. :- import_module hlds.hlds_goal. :- import_module hlds.hlds_pred. -:- import_module hlds.hlds_pred. :- import_module hlds.instmap. :- import_module hlds.make_goal. :- import_module hlds.pred_table. @@ -198,7 +197,6 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/stratify.m b/compiler/stratify.m index 8b978a58b..b367092d0 100644 --- a/compiler/stratify.m +++ b/compiler/stratify.m @@ -54,7 +54,6 @@ :- import_module check_hlds.mode_util. :- import_module hlds.hlds_error_util. :- import_module hlds.hlds_goal. -:- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. :- import_module libs. :- import_module libs.globals. diff --git a/compiler/string_switch.m b/compiler/string_switch.m index ca48247e0..fe495b3c9 100644 --- a/compiler/string_switch.m +++ b/compiler/string_switch.m @@ -81,8 +81,6 @@ :- import_module backend_libs.builtin_ops. :- import_module backend_libs.switch_util. :- import_module hlds.hlds_data. -:- import_module hlds.hlds_goal. -:- import_module hlds.hlds_llds. :- import_module ll_backend.lookup_util. :- import_module ll_backend.switch_case. :- import_module parse_tree.set_of_var. @@ -95,7 +93,6 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module std_util. %-----------------------------------------------------------------------------% diff --git a/compiler/structure_reuse.analysis.m b/compiler/structure_reuse.analysis.m index c92dc2c70..e370fb2b7 100644 --- a/compiler/structure_reuse.analysis.m +++ b/compiler/structure_reuse.analysis.m @@ -120,7 +120,6 @@ :- import_module parse_tree.status. :- import_module transform_hlds.ctgc.selector. :- import_module transform_hlds.ctgc.structure_reuse.direct. -:- import_module transform_hlds.ctgc.structure_reuse.domain. :- import_module transform_hlds.ctgc.structure_reuse.indirect. :- import_module transform_hlds.ctgc.structure_reuse.lbu. :- import_module transform_hlds.ctgc.structure_reuse.lfu. @@ -129,9 +128,7 @@ :- import_module transform_hlds.mmc_analysis. :- import_module bimap. -:- import_module bool. :- import_module int. -:- import_module io. :- import_module list. :- import_module map. :- import_module maybe. diff --git a/compiler/structure_reuse.direct.detect_garbage.m b/compiler/structure_reuse.direct.detect_garbage.m index a4ca91d97..ba5f80bb4 100644 --- a/compiler/structure_reuse.direct.detect_garbage.m +++ b/compiler/structure_reuse.direct.detect_garbage.m @@ -40,7 +40,6 @@ :- import_module hlds.vartypes. :- import_module parse_tree.prog_data. :- import_module parse_tree.prog_out. -:- import_module parse_tree.set_of_var. :- import_module transform_hlds.ctgc.datastruct. :- import_module transform_hlds.ctgc.livedata. diff --git a/compiler/structure_reuse.lbu.m b/compiler/structure_reuse.lbu.m index 7a8a2e0db..60766ed59 100644 --- a/compiler/structure_reuse.lbu.m +++ b/compiler/structure_reuse.lbu.m @@ -48,7 +48,6 @@ :- import_module list. :- import_module require. -:- import_module set. %-----------------------------------------------------------------------------% diff --git a/compiler/structure_reuse.lfu.m b/compiler/structure_reuse.lfu.m index 8bf882c2f..7f41d8407 100644 --- a/compiler/structure_reuse.lfu.m +++ b/compiler/structure_reuse.lfu.m @@ -45,7 +45,6 @@ :- import_module hlds.goal_form. :- import_module hlds.hlds_goal. :- import_module hlds.hlds_llds. -:- import_module hlds.hlds_pred. :- import_module hlds.vartypes. :- import_module parse_tree.prog_data. diff --git a/compiler/superhomogeneous.m b/compiler/superhomogeneous.m index d4b1aae35..d859c11af 100644 --- a/compiler/superhomogeneous.m +++ b/compiler/superhomogeneous.m @@ -104,10 +104,8 @@ :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_goal. :- import_module hlds.make_goal. -:- import_module hlds.make_hlds.add_clause. :- import_module hlds.make_hlds.field_access. :- import_module hlds.make_hlds.goal_expr_to_goal. -:- import_module hlds.make_hlds.qual_info. :- import_module libs.globals. % for get_maybe_from_ground_term_threshold :- import_module mdbcomp.sym_name. :- import_module parse_tree.module_qual. @@ -126,7 +124,6 @@ :- import_module map. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. :- import_module term_io. diff --git a/compiler/switch_case.m b/compiler/switch_case.m index b805eada7..9ce292af8 100644 --- a/compiler/switch_case.m +++ b/compiler/switch_case.m @@ -76,7 +76,6 @@ :- implementation. -:- import_module hlds.hlds_goal. :- import_module hlds.hlds_llds. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_goal. diff --git a/compiler/switch_detection.m b/compiler/switch_detection.m index 66096a306..78221c04d 100644 --- a/compiler/switch_detection.m +++ b/compiler/switch_detection.m @@ -71,7 +71,6 @@ :- import_module check_hlds.inst_match. :- import_module check_hlds.type_util. :- import_module hlds.goal_util. -:- import_module hlds.hlds_goal. :- import_module hlds.instmap. :- import_module hlds.passes_aux. :- import_module hlds.quantification. @@ -79,7 +78,6 @@ :- import_module libs. :- import_module libs.globals. :- import_module libs.options. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_type. :- import_module parse_tree.set_of_var. @@ -92,9 +90,7 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module set_tree234. -:- import_module string. :- import_module term. :- import_module unit. diff --git a/compiler/switch_gen.m b/compiler/switch_gen.m index 4cda39fba..a8bbb5033 100644 --- a/compiler/switch_gen.m +++ b/compiler/switch_gen.m @@ -96,7 +96,6 @@ :- implementation. :- import_module backend_libs.switch_util. -:- import_module check_hlds.type_util. :- import_module hlds.goal_form. :- import_module hlds.hlds_data. :- import_module hlds.hlds_llds. diff --git a/compiler/switch_util.m b/compiler/switch_util.m index d08093185..5c3d26c66 100644 --- a/compiler/switch_util.m +++ b/compiler/switch_util.m @@ -370,12 +370,9 @@ :- import_module backend_libs.string_encoding. :- import_module check_hlds. :- import_module check_hlds.type_util. -:- import_module hlds.hlds_data. :- import_module hlds.hlds_code_util. :- import_module libs.options. -:- import_module parse_tree.prog_type. -:- import_module char. :- import_module int. :- import_module io. :- import_module require. diff --git a/compiler/table_gen.m b/compiler/table_gen.m index 8f2c1bd7e..32350e853 100644 --- a/compiler/table_gen.m +++ b/compiler/table_gen.m @@ -62,7 +62,6 @@ :- import_module hlds.hlds_data. :- import_module hlds.hlds_error_util. :- import_module hlds.hlds_goal. -:- import_module hlds.hlds_module. :- import_module hlds.hlds_pred. :- import_module hlds.hlds_rtti. :- import_module hlds.instmap. diff --git a/compiler/tabling_analysis.m b/compiler/tabling_analysis.m index e468dbda5..26cabdb10 100644 --- a/compiler/tabling_analysis.m +++ b/compiler/tabling_analysis.m @@ -88,7 +88,6 @@ :- import_module hlds.hlds_error_util. :- import_module hlds.hlds_goal. -:- import_module hlds.hlds_pred. :- import_module hlds.vartypes. :- import_module libs.file_util. :- import_module libs.globals. diff --git a/compiler/tag_switch.m b/compiler/tag_switch.m index d0242f2a7..2ccb368e9 100644 --- a/compiler/tag_switch.m +++ b/compiler/tag_switch.m @@ -47,7 +47,6 @@ :- import_module libs.globals. :- import_module libs.options. :- import_module ll_backend.switch_case. -:- import_module parse_tree.prog_data. :- import_module assoc_list. :- import_module cord. diff --git a/compiler/term_constr_build.m b/compiler/term_constr_build.m index 18089942f..678f13065 100644 --- a/compiler/term_constr_build.m +++ b/compiler/term_constr_build.m @@ -76,7 +76,6 @@ :- import_module parse_tree.set_of_var. :- import_module transform_hlds.dependency_graph. :- import_module transform_hlds.term_constr_data. -:- import_module transform_hlds.term_constr_errors. :- import_module transform_hlds.term_constr_main. :- import_module transform_hlds.term_constr_util. diff --git a/compiler/term_constr_data.m b/compiler/term_constr_data.m index 48b955eeb..66dcd2079 100644 --- a/compiler/term_constr_data.m +++ b/compiler/term_constr_data.m @@ -381,10 +381,8 @@ :- implementation. -:- import_module hlds.hlds_pred. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_util. -:- import_module parse_tree.prog_data. :- import_module int. :- import_module require. diff --git a/compiler/term_constr_fixpoint.m b/compiler/term_constr_fixpoint.m index 9128f58a8..eec4fae0b 100644 --- a/compiler/term_constr_fixpoint.m +++ b/compiler/term_constr_fixpoint.m @@ -61,7 +61,6 @@ :- import_module libs.options. :- import_module libs.polyhedron. :- import_module parse_tree.prog_data. -:- import_module transform_hlds.term_constr_data. :- import_module transform_hlds.term_constr_main. :- import_module transform_hlds.term_constr_util. diff --git a/compiler/term_constr_initial.m b/compiler/term_constr_initial.m index 8bae4b6ca..e6800e7f9 100644 --- a/compiler/term_constr_initial.m +++ b/compiler/term_constr_initial.m @@ -84,7 +84,6 @@ :- import_module require. :- import_module set. :- import_module std_util. -:- import_module string. :- import_module term. %----------------------------------------------------------------------------% diff --git a/compiler/term_constr_main.m b/compiler/term_constr_main.m index 67baa1579..c77b63c6b 100644 --- a/compiler/term_constr_main.m +++ b/compiler/term_constr_main.m @@ -24,24 +24,24 @@ % % * Pass 0 - initial pass. % Setup information for builtin predicates and process any information -% from user annotations like termination pragmas and foreign proc. -% attributes. Also, set up information imported from `.opt' and -% `.trans_opt' files. (See term_constr_initial.m.) +% from user annotations like termination pragmas and foreign proc attributes. +% Also, set up information imported from `.opt' and `.trans_opt' files. +% (See term_constr_initial.m.) % % Each of passes 1 and 2 are run consecutively on each SCC of the -% program call-graph. This is done in bottom-up order. +% program call-graph. This is done in bottom-up order. % % * Pass 1 - interargument size relationship (IR) analysis. % -% (a) Build pass. Convert HLDS to the abstract representation (AR) -% defined in term_constr_data.m. (See term_constr_build.m.) +% (a) Build pass. Convert HLDS to the abstract representation (AR) +% defined in term_constr_data.m. (See term_constr_build.m.) % % (b) Fixpoint pass. Perform fixpoint calculation to derive IR -% information. ( See term_constr_fixpoint.m.) +% information. ( See term_constr_fixpoint.m.) % % * Pass 2 - termination. % Use the information from pass 1 to attempt to find a proof that the -% procedures in a SCC terminate. There is an example of such a proof +% procedures in a SCC terminate. There is an example of such a proof % finder in term_constr_pass2.m, although we will probably end up with % several such modules, each of which tries a different approach. % @@ -85,7 +85,7 @@ %----------------------------------------------------------------------------% % -% Types that define termination information about procedures +% Types that define termination information about procedures. % % This type is the interargument size relationships between @@ -174,7 +174,7 @@ %----------------------------------------------------------------------------% % -% Termination analysis +% Termination analysis. % % Perform termination analysis on a module. @@ -202,20 +202,16 @@ :- implementation. -:- import_module hlds.hlds_pred. :- import_module libs.file_util. :- import_module libs.globals. :- import_module libs.lp_rational. :- import_module libs.options. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.file_names. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_util. :- import_module parse_tree.status. :- import_module transform_hlds.dependency_graph. :- import_module transform_hlds.term_constr_build. -:- import_module transform_hlds.term_constr_data. -:- import_module transform_hlds.term_constr_errors. :- import_module transform_hlds.term_constr_fixpoint. :- import_module transform_hlds.term_constr_initial. :- import_module transform_hlds.term_constr_pass2. @@ -233,7 +229,7 @@ %-----------------------------------------------------------------------------% % -% The 'termination2_info' structure +% The 'termination2_info' structure. % :- type termination2_info @@ -313,8 +309,8 @@ term_constr_main.pass(!ModuleInfo, !IO) :- Pass2Options = pass2_options_init(MaxSize), % Setup termination information for builtins and compiler generated - % predicates. Setup information from termination pragmas and - % foreign proc attributes. + % predicates. Setup information from termination pragmas and foreign_proc + % attributes. term_constr_initial.preprocess_module(!ModuleInfo, !IO), % Analyse the module per SCC in bottom-up fashion. @@ -332,7 +328,7 @@ term_constr_main.pass(!ModuleInfo, !IO) :- % Analyse a single SCC. % - % Analyse a single SCC of the call graph. This will require results + % Analyse a single SCC of the call graph. This will require results % concerning SCCs lower down the call graph. % % The normal procedure for analysing a SCC is: @@ -345,7 +341,7 @@ term_constr_main.pass(!ModuleInfo, !IO) :- % (term_constr_fixpoint.m). % % (3) Use this information to try and find a proof that the procedures - % in the SCC terminate. (term_constr_pass2.m). + % in the SCC terminate. (term_constr_pass2.m). % % Exactly which of the above steps gets carried out depends upon % what (if any) additional information the user has supplied. @@ -386,7 +382,7 @@ analyse_scc(DepOrder, BuildOpts, FixpointOpts, Pass2Opts, SCC, !ModuleInfo, BuildErrors, !ModuleInfo, !IO), % We only perform the fixpoint computation for those procedures where - % we can gain meaningful information from it. We do not do it when: + % we can gain meaningful information from it. We do not do it when: % - the information is already known, or % - the argument size relationships depend upon higher-order calls. NeedsArgSize = list.filter(isnt(has_arg_size_info(!.ModuleInfo)), NeedsAR), @@ -509,7 +505,7 @@ make_opt_int(PredIds, ModuleInfo, !IO) :- output_pred_termination2_info(ModuleInfo, PredId, !IO) :- % Don't try to output termination2_info pragmas unless the analysis - % was actually run. Doing otherwise won't work because the necessary + % was actually run. Doing otherwise won't work because the necessary % information will not have been set up. module_info_get_globals(ModuleInfo, Globals), diff --git a/compiler/term_constr_pass2.m b/compiler/term_constr_pass2.m index 21d8a3631..7f2a8561e 100644 --- a/compiler/term_constr_pass2.m +++ b/compiler/term_constr_pass2.m @@ -49,10 +49,8 @@ :- implementation. -:- import_module hlds.hlds_module. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_util. -:- import_module hlds.hlds_pred. :- import_module libs.lp_rational. :- import_module libs.polyhedron. :- import_module libs.rat. diff --git a/compiler/term_constr_util.m b/compiler/term_constr_util.m index bd4ff9fb1..d52f252b6 100644 --- a/compiler/term_constr_util.m +++ b/compiler/term_constr_util.m @@ -190,10 +190,8 @@ :- implementation. :- import_module check_hlds.type_util. -:- import_module hlds.hlds_module. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_util. -:- import_module hlds.hlds_pred. :- import_module libs.rat. :- import_module transform_hlds.term_constr_errors. :- import_module transform_hlds.term_norm. diff --git a/compiler/term_errors.m b/compiler/term_errors.m index b715e90dc..c69288062 100644 --- a/compiler/term_errors.m +++ b/compiler/term_errors.m @@ -168,8 +168,6 @@ :- import_module parse_tree.error_util. :- import_module transform_hlds.term_util. -:- import_module bag. -:- import_module bool. :- import_module int. :- import_module maybe. :- import_module pair. diff --git a/compiler/term_traversal.m b/compiler/term_traversal.m index 295ee549a..bdbed82c9 100644 --- a/compiler/term_traversal.m +++ b/compiler/term_traversal.m @@ -111,7 +111,6 @@ :- import_module parse_tree.prog_type. -:- import_module assoc_list. :- import_module bool. :- import_module int. :- import_module map. diff --git a/compiler/termination.m b/compiler/termination.m index 20bd05ccf..674e405d6 100644 --- a/compiler/termination.m +++ b/compiler/termination.m @@ -86,7 +86,6 @@ :- import_module pair. :- import_module require. :- import_module set. -:- import_module string. :- import_module term. :- import_module unit. diff --git a/compiler/trace_gen.m b/compiler/trace_gen.m index 69f6dcb58..2fe3aeb63 100644 --- a/compiler/trace_gen.m +++ b/compiler/trace_gen.m @@ -250,7 +250,6 @@ :- import_module ll_backend.layout_out. :- import_module mdbcomp.prim_data. :- import_module parse_tree.prog_type. -:- import_module parse_tree.set_of_var. :- import_module bool. :- import_module cord. diff --git a/compiler/trace_params.m b/compiler/trace_params.m index 07772aa20..2be885693 100644 --- a/compiler/trace_params.m +++ b/compiler/trace_params.m @@ -129,7 +129,6 @@ :- implementation. :- import_module mdbcomp. -:- import_module mdbcomp.prim_data. :- import_module parse_tree. :- import_module parse_tree.status. diff --git a/compiler/trailing_analysis.m b/compiler/trailing_analysis.m index 35c938d54..d7682c108 100644 --- a/compiler/trailing_analysis.m +++ b/compiler/trailing_analysis.m @@ -88,7 +88,6 @@ :- import_module hlds.code_model. :- import_module hlds.hlds_error_util. :- import_module hlds.hlds_goal. -:- import_module hlds.hlds_pred. :- import_module hlds.vartypes. :- import_module libs.file_util. :- import_module libs.globals. diff --git a/compiler/trans_opt.m b/compiler/trans_opt.m index a763d0e37..78d36da73 100644 --- a/compiler/trans_opt.m +++ b/compiler/trans_opt.m @@ -84,18 +84,15 @@ :- implementation. -:- import_module hlds.hlds_pred. :- import_module libs.file_util. :- import_module libs.options. :- import_module parse_tree.error_util. :- import_module parse_tree.file_kind. :- import_module parse_tree.file_names. -:- import_module parse_tree.item_util. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.module_cmds. :- import_module parse_tree.prog_item. :- import_module parse_tree.prog_io. -:- import_module parse_tree.prog_io_error. :- import_module parse_tree.status. :- import_module transform_hlds.ctgc. :- import_module transform_hlds.ctgc.structure_reuse. @@ -110,9 +107,7 @@ :- import_module transform_hlds.trailing_analysis. :- import_module cord. -:- import_module list. :- import_module set. -:- import_module term. % for term.context_init %-----------------------------------------------------------------------------% diff --git a/compiler/transform_llds.m b/compiler/transform_llds.m index ac38e2a14..45a3032b4 100644 --- a/compiler/transform_llds.m +++ b/compiler/transform_llds.m @@ -47,7 +47,6 @@ :- import_module int. :- import_module list. :- import_module maybe. -:- import_module require. :- import_module set. :- import_module string. diff --git a/compiler/try_expand.m b/compiler/try_expand.m index dfb59bedb..2ed05522d 100644 --- a/compiler/try_expand.m +++ b/compiler/try_expand.m @@ -241,7 +241,6 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. @@ -249,10 +248,10 @@ expand_try_goals_in_module(!ModuleInfo, !Specs) :- % The exception module is implicitly imported if any try goals were seen, - % so if the exception module is not imported then we know there are no try - % goals to be expanded. - module_info_get_imported_module_names(!.ModuleInfo, ImportedModules), - ( set.contains(ImportedModules, mercury_exception_module) -> + % so if the exception module is not imported, then we know there are + % no try goals to be expanded. + module_info_get_avail_module_map(!.ModuleInfo, AvailModuleMap), + ( map.search(AvailModuleMap, mercury_exception_module, _) -> some [!Globals] ( module_info_get_globals(!.ModuleInfo, !:Globals), disable_det_warnings(OptionsToRestore, !Globals), diff --git a/compiler/type_constraints.m b/compiler/type_constraints.m index 44c287aa7..bb19756a5 100644 --- a/compiler/type_constraints.m +++ b/compiler/type_constraints.m @@ -65,7 +65,6 @@ :- import_module set. :- import_module string. :- import_module term. -:- import_module term_io. :- import_module varset. %-----------------------------------------------------------------------------% diff --git a/compiler/type_ctor_info.m b/compiler/type_ctor_info.m index eb29ef527..0e3d6285b 100644 --- a/compiler/type_ctor_info.m +++ b/compiler/type_ctor_info.m @@ -66,9 +66,8 @@ :- import_module backend_libs.foreign. :- import_module backend_libs.pseudo_type_info. -:- import_module backend_libs.rtti. :- import_module backend_libs.type_class_info. -:- import_module check_hlds. % needed for type_util, mode_util +:- import_module check_hlds. :- import_module check_hlds.type_util. :- import_module hlds.hlds_data. :- import_module hlds.hlds_pred. diff --git a/compiler/type_util.m b/compiler/type_util.m index 18246cd90..3b74b6624 100644 --- a/compiler/type_util.m +++ b/compiler/type_util.m @@ -395,11 +395,9 @@ :- import_module mdbcomp.builtin_modules. :- import_module parse_tree.builtin_lib_types. :- import_module parse_tree.prog_util. -:- import_module parse_tree.prog_type. :- import_module parse_tree.prog_type_subst. :- import_module bool. -:- import_module char. :- import_module int. :- import_module map. :- import_module require. diff --git a/compiler/typecheck_errors.m b/compiler/typecheck_errors.m index 912dc4b7b..8dd71d2ab 100644 --- a/compiler/typecheck_errors.m +++ b/compiler/typecheck_errors.m @@ -182,7 +182,6 @@ :- implementation. :- import_module hlds.hlds_error_util. -:- import_module hlds.hlds_goal. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_util. :- import_module hlds.pred_table. @@ -191,7 +190,6 @@ :- import_module libs.options. :- import_module parse_tree.mercury_to_mercury. :- import_module parse_tree.prog_io_util. -:- import_module parse_tree.prog_mode. :- import_module parse_tree.prog_out. :- import_module parse_tree.prog_type. :- import_module parse_tree.prog_type_subst. diff --git a/compiler/unify_gen.m b/compiler/unify_gen.m index a26440af0..c786174e3 100644 --- a/compiler/unify_gen.m +++ b/compiler/unify_gen.m @@ -82,17 +82,14 @@ :- import_module libs.options. :- import_module ll_backend.code_util. :- import_module ll_backend.continuation_info. -:- import_module ll_backend.global_data. :- import_module ll_backend.layout. :- import_module ll_backend.stack_layout. :- import_module mdbcomp.goal_path. :- import_module mdbcomp.sym_name. -:- import_module parse_tree.prog_data. :- import_module parse_tree.prog_out. :- import_module parse_tree.prog_type. :- import_module parse_tree.set_of_var. -:- import_module assoc_list. :- import_module bool. :- import_module cord. :- import_module int. @@ -100,7 +97,6 @@ :- import_module maybe. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. :- import_module unit. diff --git a/compiler/unify_proc.m b/compiler/unify_proc.m index fea08941e..955d54349 100644 --- a/compiler/unify_proc.m +++ b/compiler/unify_proc.m @@ -162,7 +162,6 @@ :- import_module map. :- import_module pair. :- import_module require. -:- import_module set. :- import_module string. :- import_module term. :- import_module varset. diff --git a/compiler/unique_modes.m b/compiler/unique_modes.m index 1a6a4772d..2c40fcb5e 100644 --- a/compiler/unique_modes.m +++ b/compiler/unique_modes.m @@ -99,7 +99,6 @@ :- import_module bag. :- import_module int. -:- import_module map. :- import_module maybe. :- import_module pair. :- import_module require. diff --git a/compiler/unneeded_code.m b/compiler/unneeded_code.m index d25ea1e3d..1105af111 100644 --- a/compiler/unneeded_code.m +++ b/compiler/unneeded_code.m @@ -98,7 +98,6 @@ :- import_module io. :- import_module list. :- import_module map. -:- import_module maybe. :- import_module pair. :- import_module require. :- import_module set. diff --git a/compiler/unused_args.m b/compiler/unused_args.m index b9a3f3a51..98fed1d01 100644 --- a/compiler/unused_args.m +++ b/compiler/unused_args.m @@ -88,7 +88,6 @@ :- import_module check_hlds.mode_util. :- import_module check_hlds.type_util. :- import_module hlds.goal_util. -:- import_module hlds.hlds_data. :- import_module hlds.hlds_goal. :- import_module hlds.hlds_out. :- import_module hlds.hlds_out.hlds_out_util. diff --git a/compiler/unused_imports.m b/compiler/unused_imports.m index d634b1102..b6f7966d4 100644 --- a/compiler/unused_imports.m +++ b/compiler/unused_imports.m @@ -32,21 +32,21 @@ :- import_module parse_tree. :- import_module parse_tree.error_util. -:- import_module io. :- import_module list. % This predicate issues a warning for each import_module % which is not directly used in this module, plus those % which are in the interface but should be in the implementation. % -:- pred warn_about_unused_imports(module_info::in, list(error_spec)::out, - io::di, io::uo) is det. +:- pred warn_about_unused_imports(module_info::in, list(error_spec)::out) + is det. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% :- implementation. +:- import_module hlds.const_struct. :- import_module hlds.hlds_clauses. :- import_module hlds.hlds_data. :- import_module hlds.hlds_goal. @@ -54,91 +54,245 @@ :- import_module mdbcomp. :- import_module mdbcomp.builtin_modules. :- import_module mdbcomp.sym_name. -:- import_module parse_tree.file_names. :- import_module parse_tree.prog_data. +:- import_module parse_tree.prog_item. :- import_module parse_tree.status. +:- import_module assoc_list. :- import_module bool. +:- import_module cord. :- import_module map. :- import_module maybe. +:- import_module pair. :- import_module set. -:- import_module string. :- import_module term. %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -warn_about_unused_imports(ModuleInfo, !:Specs, !IO) :- - module_info_get_globals(ModuleInfo, Globals), +warn_about_unused_imports(ModuleInfo, Specs) :- module_info_get_name(ModuleInfo, ModuleName), - module_name_to_file_name(Globals, ModuleName, ".m", do_not_create_dirs, - FileName, !IO), - find_all_non_warn_modules(ModuleInfo, UsedModules), + module_info_get_avail_module_map(ModuleInfo, AvailModuleMap), + map.to_assoc_list(AvailModuleMap, ModuleAvails), + get_avail_modules_anywhere_interface(ModuleAvails, + cord.init, AvailAnywhereCord, + cord.init, AvailInterfaceCord), + set.sorted_list_to_set(cord.list(AvailAnywhereCord), + AvailAnywhereModules), + set.sorted_list_to_set(cord.list(AvailInterfaceCord), + AvailInterfaceModules), + + UsedInInterface = UsedModules ^ int_used_modules, + UsedInImplementation = UsedModules ^ impl_used_modules, + UsedAnywhere = set.union(UsedInInterface, UsedInImplementation), + % The unused imports is simply the set of all imports minus all the % used modules. - module_info_get_imported_module_names(ModuleInfo, ImportedModules), - UsedInImplementation = UsedModules ^ impl_used_modules, - UnusedImports = ImportedModules `set.difference` - (UsedInInterface `set.union` UsedInImplementation), - - ( set.is_non_empty(UnusedImports) -> - ImportSpec = generate_warning(ModuleName, FileName, - set.to_sorted_list(UnusedImports), ""), - !:Specs = [ImportSpec] - ; - !:Specs = [] - ), + UnusedAnywhereImports = set.difference(AvailAnywhereModules, UsedAnywhere), % Determine the modules imported in the interface but not used in % the interface. - module_info_get_interface_module_names(ModuleInfo, InterfaceImports), - UsedInInterface = UsedModules ^ int_used_modules, - UnusedInterfaceImports = (InterfaceImports - `set.difference` UsedInInterface) `set.difference` UnusedImports, + UnusedInterfaceImports = + set.difference(AvailInterfaceModules, UsedInInterface), - ( set.is_non_empty(UnusedInterfaceImports) -> - InterfaceImportSpec = generate_warning(ModuleName, FileName, - set.to_sorted_list(UnusedInterfaceImports), " interface"), - !:Specs = [InterfaceImportSpec | !.Specs] + map.foldl( + maybe_warn_about_avail(ModuleName, + UnusedAnywhereImports, UnusedInterfaceImports), + AvailModuleMap, [], Specs). + +:- pred get_avail_modules_anywhere_interface( + assoc_list(module_name, avail_module_entry)::in, + cord(module_name)::in, cord(module_name)::out, + cord(module_name)::in, cord(module_name)::out) is det. + +get_avail_modules_anywhere_interface([], + !AvailAnywhereCord, !AvailInterfaceCord). +get_avail_modules_anywhere_interface([ModuleEntry | ModuleEntries], + !AvailAnywhereCord, !AvailInterfaceCord) :- + ModuleEntry = ModuleName - Entry, + Entry = avail_module_entry(Section, _ImportOrUse, _Context), + !:AvailAnywhereCord = cord.snoc(!.AvailAnywhereCord, ModuleName), + ( + Section = ms_interface, + !:AvailInterfaceCord = cord.snoc(!.AvailInterfaceCord, ModuleName) ; - true + Section = ms_implementation + ), + get_avail_modules_anywhere_interface(ModuleEntries, + !AvailAnywhereCord, !AvailInterfaceCord). + +:- pred maybe_warn_about_avail(module_name::in, + set(module_name)::in, set(module_name)::in, + module_name::in, avail_module_entry::in, + list(error_spec)::in, list(error_spec)::out) is det. + +maybe_warn_about_avail(TopModuleName, + UnusedAnywhereImports, UnusedInterfaceImports, + ModuleName, AvailEntry, !Specs) :- + AvailEntry = avail_module_entry(Section, ImportOrUse, Avails), + list.sort(compare_avails, Avails, SortedAvails), + ( + SortedAvails = [] + ; + SortedAvails = [HeadAvail | _], + HeadAvail = avail_module(_, _, HeadContext), + maybe_generate_redundant_avail_warnings(ModuleName, SortedAvails, + [], !Specs), + ( if + set.member(ModuleName, UnusedAnywhereImports) + then + AnywhereSpec = generate_unused_warning(TopModuleName, + ModuleName, ImportOrUse, HeadContext, aoi_anywhere), + !:Specs = [AnywhereSpec | !.Specs], + AnywhereWarning = yes + else + AnywhereWarning = no + ), + % Do not generate a report that a module is unused in the interface + % if we have generated a report that it is unused *anywhere*. + ( if + Section = ms_interface, + set.member(ModuleName, UnusedInterfaceImports), + AnywhereWarning = no + then + InterfaceSpec = generate_unused_warning(TopModuleName, + ModuleName, ImportOrUse, HeadContext, aoi_interface), + !:Specs = [InterfaceSpec | !.Specs] + else + true + ) ). -:- func generate_warning(module_name, string, list(module_name), string) - = error_spec. +:- pred compare_avails(avail_module::in, avail_module::in, + comparison_result::out) is det. -generate_warning(ModuleName, FileName, UnusedImports, Location) = Spec :- - term.context_init(FileName, 1, Context), - ModuleWord = choose_number(UnusedImports, "module", "modules"), - IsOrAre = is_or_are(UnusedImports), - - ( Location = "" -> - InThe = "", - LocationOf = "" +compare_avails(AvailA, AvailB, Result) :- + % Put interface before implementation, and import before use, + % so that less general entries (entries that grant fewer permissions) + % are always *after* more general entries. + AvailA = avail_module(SectionA, ImportOrUseA, ContextA), + AvailB = avail_module(SectionB, ImportOrUseB, ContextB), + ( + SectionA = ms_interface, + SectionB = ms_implementation, + Result = (>) ; - InThe = " in the", - LocationOf = Location ++ " of" - ), + SectionA = ms_implementation, + SectionB = ms_interface, + Result = (>) + ; + ( SectionA = ms_interface, SectionB = ms_interface + ; SectionA = ms_implementation, SectionB = ms_implementation + ), + ( + ImportOrUseA = import_decl, + ImportOrUseB = use_decl, + Result = (>) + ; + ImportOrUseA = use_decl, + ImportOrUseB = import_decl, + Result = (>) + ; + ( ImportOrUseA = import_decl, ImportOrUseB = import_decl + ; ImportOrUseA = use_decl, ImportOrUseB = use_decl + ), + compare(Result, ContextA, ContextB) + ) + ). - UnusedSymNames = list.map(wrap_module_name, UnusedImports), - Pieces = [words("In " ++ LocationOf ++ " module" ), sym_name(ModuleName), - suffix(":"), nl, - words("warning:"), words(ModuleWord)] ++ - component_list_to_pieces(UnusedSymNames) ++ - [fixed(IsOrAre), words("imported, "), - words("but"), fixed(IsOrAre), - words("not used" ++ InThe ++ Location ++ ".")], +:- pred maybe_generate_redundant_avail_warnings(module_name::in, + list(avail_module)::in, list(avail_module)::in, + list(error_spec)::in, list(error_spec)::out) is det. + +maybe_generate_redundant_avail_warnings(_ModuleName, [], _, !Specs). +maybe_generate_redundant_avail_warnings(ModuleName, [Avail | Avails], + !.PrevAvails, !Specs) :- + list.foldl(add_msg_if_avail_as_general(ModuleName, Avail), !.PrevAvails, + [], PrevMsgs), + ( + PrevMsgs = [], + % O(n^2), but the usual value of n is *very* small. + !:PrevAvails = !.PrevAvails ++ [Avail] + ; + PrevMsgs = [_ | _], + Avail = avail_module(_Section, ImportOrUse, Context), + DeclName = import_or_use_decl_name(ImportOrUse), + MainPieces = [words("This"), decl(DeclName), words("declaration"), + words("for"), sym_name(ModuleName), words("is redundant."), nl], + MainMsg = simple_msg(Context, [always(MainPieces)]), + Spec = error_spec(severity_informational, phase_code_gen, + [MainMsg | PrevMsgs]), + !:Specs = [Spec | !.Specs] + ), + maybe_generate_redundant_avail_warnings(ModuleName, Avails, + !.PrevAvails, !Specs). + + % add_msg_if_avail_as_general(ModuleName, ThisAvail, PrevAvail, !Msgs): + % + % If PrevEntry is at least as general as ThisEntry, add a message + % about PrevEntry being a previous import or use declaration + % for ModuleName to !Msgs. + % +:- pred add_msg_if_avail_as_general(module_name::in, + avail_module::in, avail_module::in, + list(error_msg)::in, list(error_msg)::out) is det. + +add_msg_if_avail_as_general(ModuleName, ThisAvail, PrevAvail, !Msgs) :- + ThisAvail = avail_module(ThisSection, ThisImportOrUse, _ThisContext), + PrevAvail = avail_module(PrevSection, PrevImportOrUse, PrevContext), + ( if + ( + % Does this entry grant extra permissions about where ModuleName + % may be used? + PrevSection = ms_implementation, + ThisSection = ms_interface + ; + % Does this entry grant extra permissions about the use of + % ModuleName without explicit qualification? + PrevImportOrUse = use_decl, + ThisImportOrUse = import_decl + ) + then + true + else + DeclName = import_or_use_decl_name(PrevImportOrUse), + Pieces = [words("This is the location of the previous"), + decl(DeclName), words("declaration"), + words("for module"), sym_name(ModuleName), + words("that makes this one redundant."), nl], + Msg = simple_msg(PrevContext, [always(Pieces)]), + !:Msgs = [Msg | !.Msgs] + ). + +:- type anywhere_or_interface + ---> aoi_anywhere + ; aoi_interface. + +:- func generate_unused_warning(module_name, module_name, import_or_use, + prog_context, anywhere_or_interface) = error_spec. + +generate_unused_warning(TopModuleName, UnusedModuleName, ImportOrUse, + Context, AnywhereOrInterface) = Spec :- + ( + AnywhereOrInterface = aoi_anywhere, + DeclInTheLocn = "", + NotUsedInTheLocn = "anywhere in the module" + ; + AnywhereOrInterface = aoi_interface, + DeclInTheLocn = "in the interface", + NotUsedInTheLocn = "in the interface" + ), + ImportOrUseDeclName = import_or_use_decl_name(ImportOrUse), + Pieces = [words("In module" ), sym_name(TopModuleName), suffix(":"), nl, + words("warning: module"), sym_name(UnusedModuleName), + words("has a"), decl(ImportOrUseDeclName), + words("declaration"), words(DeclInTheLocn), suffix(","), + words("but is not used"), words(NotUsedInTheLocn), suffix("."), nl], Msg = simple_msg(Context, [always(Pieces)]), Spec = error_spec(severity_warning, phase_code_gen, [Msg]). -%-----------------------------------------------------------------------------% - -:- func wrap_module_name(module_name) = format_component. - -wrap_module_name(SymName) = sym_name(SymName). - %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -181,7 +335,11 @@ find_all_non_warn_modules(ModuleInfo, !:UsedModules) :- map.foldl(class_used_modules, ClassTable, !UsedModules), module_info_get_instance_table(ModuleInfo, InstanceTable), - map.foldl(instance_used_modules, InstanceTable, !UsedModules), + map.foldl(class_instances_used_modules, InstanceTable, !UsedModules), + + module_info_get_const_struct_db(ModuleInfo, ConstStructDb), + const_struct_db_get_structs(ConstStructDb, ConstStructs), + list.foldl(const_struct_used_modules, ConstStructs, !UsedModules), module_info_get_preds(ModuleInfo, PredTable), map.foldl(pred_info_used_modules, PredTable, !UsedModules). @@ -301,29 +459,45 @@ class_used_modules(class_id(Name, _Arity), ClassDefn, !UsedModules) :- %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% -:- pred instance_used_modules(class_id::in, list(hlds_instance_defn)::in, +:- pred class_instances_used_modules(class_id::in, + list(hlds_instance_defn)::in, used_modules::in, used_modules::out) is det. + +class_instances_used_modules(ClassId, InstanceDefns, !UsedModules) :- + list.foldl(instance_used_modules(ClassId), InstanceDefns, !UsedModules). + +:- pred instance_used_modules(class_id::in, hlds_instance_defn::in, used_modules::in, used_modules::out) is det. -instance_used_modules(ClassId, InstanceDefns, !UsedModules) :- - list.foldl(instance_used_modules_2(ClassId), InstanceDefns, !UsedModules). +instance_used_modules(ClassId, InstanceDefn, !UsedModules) :- + ClassId = class_id(Name, _Arity), + InstanceDefn = hlds_instance_defn(_InstanceModule, ImportStatus, + _Context, Constraints, Types, _OriginalTypes, _Body, + _MaybePredProcIds, _VarSet, _ProofMap), -:- pred instance_used_modules_2(class_id::in, hlds_instance_defn::in, - used_modules::in, used_modules::out) is det. + Visibility = item_visibility(ImportStatus), + % XXX When it sees an abstract instance declaration, the code of + % add_pass_2_instance makes the status of the instance abstract, + % but it does so by effectively setting ImportStatus to abstract_imported, + % the second half of which is a lie. + % + % We should process Name and Types only if the instance is defined + % in this module, but we cannot trust the value of DefinedInThisModule + % in these cases. Since it is better to miss some warnings than to + % generate warnings for perfectly good code, we always process them. + % + % The Constraints will be empty for instances in which DefinedInThisModule + % is wrong, so it is OK to traverse them only if DefinedInThisModule = yes. + record_sym_name_module_as_used(Visibility, Name, !UsedModules), + list.foldl(mer_type_used_modules(Visibility), Types, !UsedModules), -instance_used_modules_2(class_id(Name, _Arity), InstanceDefn, !UsedModules) :- - ImportStatus = InstanceDefn ^ instance_status, DefinedInThisModule = status_defined_in_this_module(ImportStatus), ( DefinedInThisModule = yes, % The methods of the class are stored in the pred_table and hence % will be processed by pred_info_used_modules. % XXX is this true? - Visibility = item_visibility(ImportStatus), - record_sym_name_module_as_used(Visibility, Name, !UsedModules), - list.foldl(prog_constraint_used_module(Visibility), - InstanceDefn ^ instance_constraints, !UsedModules), - list.foldl(mer_type_used_modules(Visibility), - InstanceDefn ^ instance_types, !UsedModules) + list.foldl(prog_constraint_used_module(Visibility), Constraints, + !UsedModules) ; DefinedInThisModule = no ). @@ -331,6 +505,34 @@ instance_used_modules_2(class_id(Name, _Arity), InstanceDefn, !UsedModules) :- %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% +:- pred const_struct_used_modules(pair(int, const_struct)::in, + used_modules::in, used_modules::out) is det. + +const_struct_used_modules(_ConstNum - ConstStruct, !UsedModules) :- + % Every const_struct in the const_struct_db was put there because + % it is used in module. None of the uses can be in the interface. + + ConstStruct = const_struct(ConsId, ConstStructArgs, Type, Inst), + cons_id_used_modules(visibility_private, ConsId, !UsedModules), + list.foldl(const_struct_arg_used_modules, ConstStructArgs, !UsedModules), + mer_type_used_modules(visibility_private, Type, !UsedModules), + mer_inst_used_modules(visibility_private, Inst, !UsedModules). + +:- pred const_struct_arg_used_modules(const_struct_arg::in, + used_modules::in, used_modules::out) is det. + +const_struct_arg_used_modules(ConstStructArg, !UsedModules) :- + ( + ConstStructArg = csa_const_struct(_ConstNum) + ; + ConstStructArg = csa_constant(ConsId, Type), + cons_id_used_modules(visibility_private, ConsId, !UsedModules), + mer_type_used_modules(visibility_private, Type, !UsedModules) + ). + +%-----------------------------------------------------------------------------% +%-----------------------------------------------------------------------------% + :- pred pred_info_used_modules(pred_id::in, pred_info::in, used_modules::in, used_modules::out) is det. @@ -395,15 +597,16 @@ clause_used_modules(Clause, !UsedModules) :- hlds_goal_used_modules(Goal, !UsedModules) :- Goal = hlds_goal(GoalExpr, _), ( - GoalExpr = unify(_, Rhs, _, _, _), - unify_rhs_used_modules(Rhs, !UsedModules) + GoalExpr = unify(_, RHS, _, _, _), + unify_rhs_used_modules(RHS, !UsedModules) ; GoalExpr = plain_call(_, _, _, _, _, SymName), - record_sym_name_module_as_used(visibility_private, SymName, !UsedModules), + record_sym_name_module_as_used(visibility_private, SymName, + !UsedModules), Name = unqualify_name(SymName), - ( Name = "format" -> + ( if Name = "format" then record_format_modules_as_used(!UsedModules) - ; + else true ) ; @@ -473,12 +676,16 @@ case_used_modules(Case, !UsedModules) :- :- pred unify_rhs_used_modules(unify_rhs::in, used_modules::in, used_modules::out) is det. -unify_rhs_used_modules(rhs_var(_), !UsedModules). -unify_rhs_used_modules(rhs_functor(ConsId, _, _), !UsedModules) :- - cons_id_used_modules(visibility_private, ConsId, !UsedModules). -unify_rhs_used_modules(rhs_lambda_goal(_, _, _, _, _, _, _, _, Goal), - !UsedModules) :- - hlds_goal_used_modules(Goal, !UsedModules). +unify_rhs_used_modules(RHS, !UsedModules) :- + ( + RHS = rhs_var(_) + ; + RHS = rhs_functor(ConsId, _, _), + cons_id_used_modules(visibility_private, ConsId, !UsedModules) + ; + RHS = rhs_lambda_goal(_, _, _, _, _, _, _, _, Goal), + hlds_goal_used_modules(Goal, !UsedModules) + ). :- pred cons_id_used_modules(item_visibility::in, cons_id::in, used_modules::in, used_modules::out) is det. @@ -519,32 +726,46 @@ cons_id_used_modules(Visibility, ConsId, !UsedModules) :- used_modules::in, used_modules::out) is det. mer_type_used_modules(Visibility, Type, !UsedModules) :- - mer_type_used_modules_2(Visibility, Type, !UsedModules). - -:- pred mer_type_used_modules_2(item_visibility::in, mer_type::in, - used_modules::in, used_modules::out) is det. - -mer_type_used_modules_2(_Status, type_variable(_, _), !UsedModules). -mer_type_used_modules_2(Visibility, defined_type(Name, Args, _), - !UsedModules) :- - record_sym_name_module_as_used(Visibility, Name, !UsedModules), - list.foldl(mer_type_used_modules(Visibility), Args, !UsedModules). -mer_type_used_modules_2(_Status, builtin_type(_), !UsedModules). -mer_type_used_modules_2(Visibility, - higher_order_type(Args, MaybeReturn, _, _), !UsedModules) :- - list.foldl(mer_type_used_modules(Visibility), Args, !UsedModules), ( - MaybeReturn = yes(Return), - mer_type_used_modules(Visibility, Return, !UsedModules) + Type = type_variable(_, _) ; - MaybeReturn = no + Type = defined_type(Name, Args, _), + record_sym_name_module_as_used(Visibility, Name, !UsedModules), + list.foldl(mer_type_used_modules(Visibility), Args, !UsedModules) + ; + Type = builtin_type(BuiltinType), + ( + ( BuiltinType = builtin_type_int + ; BuiltinType = builtin_type_float + ; BuiltinType = builtin_type_string + ) + % You don't need to import int.m, float.m or string.m to use these. + ; + BuiltinType = builtin_type_char, + % You *do* need to import char.m to use these. + CharModuleName = mercury_std_lib_module_name(unqualified("char")), + record_module_and_ancestors_as_used(Visibility, CharModuleName, + !UsedModules) + ) + ; + Type = higher_order_type(Args, MaybeReturn, _, _), + list.foldl(mer_type_used_modules(Visibility), Args, !UsedModules), + ( + MaybeReturn = yes(Return), + mer_type_used_modules(Visibility, Return, !UsedModules) + ; + MaybeReturn = no + ) + ; + Type = tuple_type(ArgTypes, _), + list.foldl(mer_type_used_modules(Visibility), ArgTypes, !UsedModules) + ; + Type = apply_n_type(_, ArgTypes, _), + list.foldl(mer_type_used_modules(Visibility), ArgTypes, !UsedModules) + ; + Type = kinded_type(ArgType, _), + mer_type_used_modules(Visibility, ArgType, !UsedModules) ). -mer_type_used_modules_2(Visibility, tuple_type(Args, _), !UsedModules) :- - list.foldl(mer_type_used_modules(Visibility), Args, !UsedModules). -mer_type_used_modules_2(Visibility, apply_n_type(_, Args, _), !UsedModules) :- - list.foldl(mer_type_used_modules(Visibility), Args, !UsedModules). -mer_type_used_modules_2(Visibility, kinded_type(Arg, _), !UsedModules) :- - mer_type_used_modules(Visibility, Arg, !UsedModules). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -552,13 +773,16 @@ mer_type_used_modules_2(Visibility, kinded_type(Arg, _), !UsedModules) :- :- pred mer_mode_used_modules(item_visibility::in, mer_mode::in, used_modules::in, used_modules::out) is det. -mer_mode_used_modules(Visibility, Inst0 -> Inst, !UsedModules) :- - mer_inst_used_modules(Visibility, Inst0, !UsedModules), - mer_inst_used_modules(Visibility, Inst, !UsedModules). -mer_mode_used_modules(Visibility, user_defined_mode(Name, Insts), - !UsedModules) :- - record_sym_name_module_as_used(Visibility, Name, !UsedModules), - list.foldl(mer_inst_used_modules(Visibility), Insts, !UsedModules). +mer_mode_used_modules(Visibility, Mode, !UsedModules) :- + ( + Mode = (Inst0 -> Inst), + mer_inst_used_modules(Visibility, Inst0, !UsedModules), + mer_inst_used_modules(Visibility, Inst, !UsedModules) + ; + Mode = user_defined_mode(Name, Insts), + record_sym_name_module_as_used(Visibility, Name, !UsedModules), + list.foldl(mer_inst_used_modules(Visibility), Insts, !UsedModules) + ). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -602,18 +826,21 @@ mer_inst_used_modules(Visibility, Inst, !UsedModules) :- :- pred bound_inst_info_used_modules(item_visibility::in, bound_inst::in, used_modules::in, used_modules::out) is det. -bound_inst_info_used_modules(Visibility, bound_functor(ConsId, Insts), - !UsedModules) :- +bound_inst_info_used_modules(Visibility, BoundFunctor, !UsedModules) :- + BoundFunctor = bound_functor(ConsId, Insts), cons_id_used_modules(Visibility, ConsId, !UsedModules), list.foldl(mer_inst_used_modules(Visibility), Insts, !UsedModules). :- pred ho_inst_info_used_modules(item_visibility::in, ho_inst_info::in, used_modules::in, used_modules::out) is det. -ho_inst_info_used_modules(Visibility, - higher_order(pred_inst_info(_, Modes, _, _)), !UsedModules) :- - list.foldl(mer_mode_used_modules(Visibility), Modes, !UsedModules). -ho_inst_info_used_modules(_, none, !UsedModules). +ho_inst_info_used_modules(Visibility, HOInstInfo, !UsedModules) :- + ( + HOInstInfo = higher_order(pred_inst_info(_, Modes, _, _)), + list.foldl(mer_mode_used_modules(Visibility), Modes, !UsedModules) + ; + HOInstInfo = none + ). %-----------------------------------------------------------------------------% diff --git a/compiler/var_locn.m b/compiler/var_locn.m index 5b9ccf5ae..e640b2d34 100644 --- a/compiler/var_locn.m +++ b/compiler/var_locn.m @@ -406,8 +406,6 @@ :- import_module backend_libs.builtin_ops. :- import_module check_hlds.type_util. -:- import_module libs.globals. -:- import_module libs.options. :- import_module ll_backend.code_util. :- import_module ll_backend.exprn_aux. :- import_module parse_tree.builtin_lib_types. diff --git a/compiler/write_module_interface_files.m b/compiler/write_module_interface_files.m index d4146e749..deace6ad0 100644 --- a/compiler/write_module_interface_files.m +++ b/compiler/write_module_interface_files.m @@ -108,7 +108,6 @@ :- import_module parse_tree.modules. % undesirable dependency :- import_module parse_tree.check_raw_comp_unit.% undesirable dependency :- import_module parse_tree.prog_data. -:- import_module parse_tree.prog_io_error. :- import_module parse_tree.prog_mutable. :- import_module parse_tree.prog_type. :- import_module parse_tree.read_modules. diff --git a/compiler/xml_documentation.m b/compiler/xml_documentation.m index c055d0edb..d9c29f107 100644 --- a/compiler/xml_documentation.m +++ b/compiler/xml_documentation.m @@ -44,6 +44,7 @@ :- import_module parse_tree.error_util. :- import_module parse_tree.file_names. :- import_module parse_tree.prog_data. +:- import_module parse_tree.prog_item. :- import_module parse_tree.source_file_map. :- import_module parse_tree.status. @@ -185,13 +186,13 @@ is_not_comment_char(C) :- :- func maybe_add_comment(comments, prog_context, xml) = xml. maybe_add_comment(Comments, Context, Xml) = - ( Xml = elem(N, As, Cs) -> - ( Comment = get_comment(Comments, Context), Comment \= "" -> + ( if Xml = elem(N, As, Cs) then + ( if Comment = get_comment(Comments, Context), Comment \= "" then elem(N, As, [elem("comment", [], [data(Comment)]) | Cs]) - ; + else Xml ) - ; + else unexpected($module, $pred, "not an element") ). @@ -203,11 +204,11 @@ get_comment(Comments, context(_, Line)) = % XXX At a later date this hard-coded strategy should be made % more flexible. What I imagine is that the user would pass a string % saying in what order they wish to search for comments. - ( comment_on_current_line(Comments, Line, C) -> + ( if comment_on_current_line(Comments, Line, C) then C - ; comment_directly_above(Comments, Line, C) -> + else if comment_directly_above(Comments, Line, C) then C - ; + else "" ). @@ -241,7 +242,7 @@ comment_directly_above(Comments, Line, Comment) :- :- func get_comment_forwards(comments, int) = string. get_comment_forwards(Comments, Line) = Comment :- - ( map.search(Comments ^ line_types, Line, LineType) -> + ( if map.search(Comments ^ line_types, Line, LineType) then ( LineType = comment(CurrentComment), CommentBelow = get_comment_forwards(Comments, Line + 1), @@ -253,7 +254,7 @@ get_comment_forwards(Comments, Line) = Comment :- ), Comment = "" ) - ; + else Comment = "" ). @@ -264,7 +265,7 @@ get_comment_forwards(Comments, Line) = Comment :- :- func get_comment_backwards(comments, int) = string. get_comment_backwards(Comments, Line) = Comment :- - ( map.search(Comments ^ line_types, Line, LineType) -> + ( if map.search(Comments ^ line_types, Line, LineType) then ( LineType = comment(CurrentComment), CommentAbove = get_comment_backwards(Comments, Line - 1), @@ -276,7 +277,7 @@ get_comment_backwards(Comments, Line) = Comment :- ), Comment = "" ) - ; + else Comment = "" ). @@ -290,14 +291,10 @@ get_comment_backwards(Comments, Line) = Comment :- (to_xml(module_info_xml_doc(Comments, ModuleComment, ModuleInfo)) = Xml :- CommentXml = elem("comment", [], [data(ModuleComment)]), - module_info_get_interface_module_names(ModuleInfo, - InterfaceImports), - module_info_get_imported_module_names(ModuleInfo, - ImportedModules0), - ImportedModules = - ImportedModules0 `difference` set(all_builtin_modules), - set.fold(import_documentation(InterfaceImports), - ImportedModules, [], ImportsXml), + module_info_get_avail_module_map(ModuleInfo, AvailModuleMap), + BuiltinModuleNames = set.list_to_set(all_builtin_modules), + map.foldl(maybe_add_import_documentation(BuiltinModuleNames), + AvailModuleMap, [], ImportsXml), ImportXml = elem("imports", [], ImportsXml), module_info_get_type_table(ModuleInfo, TypeTable), @@ -322,20 +319,36 @@ get_comment_backwards(Comments, Line) = Comment :- %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% - % Output the documentation for one import + % Output the documentation for one import_module or use_module declaration. % -:- pred import_documentation(set(module_name)::in, module_name::in, - list(xml)::in, list(xml)::out) is det. +:- pred maybe_add_import_documentation(set(module_name)::in, + module_name::in, avail_module_entry::in, list(xml)::in, list(xml)::out) + is det. -import_documentation(InterfaceImportedModules, ImportedModule, !Xmls) :- - XmlName = name_to_xml(ImportedModule), - ( ImportedModule `set.member` InterfaceImportedModules -> - XmlVisibility = visibility_to_xml(status_exported) - ; - XmlVisibility = visibility_to_xml(status_local) - ), - Xml = elem("import", [], [XmlName, XmlVisibility]), - !:Xmls = [Xml | !.Xmls]. +maybe_add_import_documentation(BuiltinModuleNames, ModuleName, AvailEntry, + !Xmls) :- + ( if set.member(ModuleName, BuiltinModuleNames) then + true + else + XmlName = name_to_xml(ModuleName), + AvailEntry = avail_module_entry(Section, ImportOrUse, _Avails), + ( + Section = ms_interface, + XmlVisibility = visibility_to_xml(status_exported) + ; + Section = ms_implementation, + XmlVisibility = visibility_to_xml(status_local) + ), + ( + ImportOrUse = import_decl, + ImportOrUseWord = "import" + ; + ImportOrUse = use_decl, + ImportOrUseWord = "use" + ), + Xml = elem(ImportOrUseWord, [], [XmlName, XmlVisibility]), + !:Xmls = [Xml | !.Xmls] + ). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------% @@ -477,14 +490,14 @@ pred_documentation(C, _PredId, PredInfo, !Xml) :- pred_info_get_origin(PredInfo, Origin), pred_info_get_markers(PredInfo, Markers), - ( + ( if status_defined_in_this_module(ImportStatus) = yes, Origin = origin_user(_), not check_marker(Markers, marker_class_method) - -> + then Xml = predicate_documentation(C, PredInfo), !:Xml = [Xml | !.Xml] - ; + else true ). @@ -542,9 +555,9 @@ get_orig_arg_types(PredInfo) = Types :- :- func keep_last_n(int, list(T)) = list(T). keep_last_n(N, L0) = - ( list.drop(list.length(L0) - N, L0, L) -> + ( if list.drop(list.length(L0) - N, L0, L) then L - ; + else func_error("keep_last_n") ). @@ -807,13 +820,13 @@ prog_constraint_to_xml(TVarset, Constraint) = Xml :- :- func visibility_to_xml(import_status) = xml. visibility_to_xml(Status) = tagged_string("visibility", Visibility) :- - ( status_defined_in_impl_section(Status) = yes -> - ( Status = status_abstract_exported -> + ( if status_defined_in_impl_section(Status) = yes then + ( if Status = status_abstract_exported then Visibility = "abstract" - ; + else Visibility = "implementation" ) - ; + else Visibility = "interface" ). diff --git a/deep_profiler/analysis_utils.m b/deep_profiler/analysis_utils.m index 15eb9f602..94d225e3a 100644 --- a/deep_profiler/analysis_utils.m +++ b/deep_profiler/analysis_utils.m @@ -117,7 +117,6 @@ :- import_module int. :- import_module io. :- import_module message. -:- import_module pair. :- import_module require. :- import_module string. diff --git a/deep_profiler/autopar_annotate.m b/deep_profiler/autopar_annotate.m index 5fb277979..618df2408 100644 --- a/deep_profiler/autopar_annotate.m +++ b/deep_profiler/autopar_annotate.m @@ -45,8 +45,6 @@ :- implementation. -:- import_module mdbcomp.goal_path. - :- import_module list. %----------------------------------------------------------------------------% diff --git a/deep_profiler/autopar_search_callgraph.m b/deep_profiler/autopar_search_callgraph.m index c792fa475..9f86cbd0b 100644 --- a/deep_profiler/autopar_search_callgraph.m +++ b/deep_profiler/autopar_search_callgraph.m @@ -51,10 +51,8 @@ :- import_module measurement_units. :- import_module measurements. :- import_module program_representation_utils. -:- import_module read_profile. :- import_module recursion_patterns. :- import_module report. -:- import_module var_use_analysis. :- import_module array. :- import_module assoc_list. @@ -63,7 +61,6 @@ :- import_module float. :- import_module int. :- import_module io. -:- import_module lazy. :- import_module list. :- import_module map. :- import_module maybe. diff --git a/deep_profiler/callgraph.m b/deep_profiler/callgraph.m index 327e6be91..43fff776d 100644 --- a/deep_profiler/callgraph.m +++ b/deep_profiler/callgraph.m @@ -37,7 +37,6 @@ :- import_module array_util. :- import_module cliques. -:- import_module profile. :- import_module int. :- import_module io. diff --git a/deep_profiler/mdprof_create_feedback.m b/deep_profiler/mdprof_create_feedback.m index 083af3953..87087cc7e 100644 --- a/deep_profiler/mdprof_create_feedback.m +++ b/deep_profiler/mdprof_create_feedback.m @@ -28,7 +28,6 @@ :- implementation. -:- import_module conf. :- import_module mdbcomp. :- import_module mdbcomp.feedback. :- import_module mdbcomp.feedback.automatic_parallelism. diff --git a/deep_profiler/mdprof_report_feedback.m b/deep_profiler/mdprof_report_feedback.m index ae48436f4..dd60480e3 100644 --- a/deep_profiler/mdprof_report_feedback.m +++ b/deep_profiler/mdprof_report_feedback.m @@ -30,7 +30,6 @@ :- import_module mdbcomp. :- import_module mdbcomp.feedback. -:- import_module mdbcomp.feedback.automatic_parallelism. :- import_module mdprof_fb. :- import_module mdprof_fb.automatic_parallelism. :- import_module mdprof_fb.automatic_parallelism.autopar_reports. diff --git a/deep_profiler/query.m b/deep_profiler/query.m index a883685e3..5f7b5fd34 100644 --- a/deep_profiler/query.m +++ b/deep_profiler/query.m @@ -375,7 +375,6 @@ :- import_module io. :- import_module list. :- import_module math. -:- import_module maybe. :- import_module string. :- import_module univ. diff --git a/deep_profiler/recursion_patterns.m b/deep_profiler/recursion_patterns.m index 2b99cc859..7c2597d88 100644 --- a/deep_profiler/recursion_patterns.m +++ b/deep_profiler/recursion_patterns.m @@ -52,8 +52,6 @@ :- import_module mdbcomp.goal_path. :- import_module mdbcomp.program_representation. :- import_module measurement_units. -:- import_module measurements. -:- import_module report. :- import_module array. :- import_module assoc_list. diff --git a/deep_profiler/startup.m b/deep_profiler/startup.m index 6896ccb1a..abb5b600f 100644 --- a/deep_profiler/startup.m +++ b/deep_profiler/startup.m @@ -50,7 +50,6 @@ :- import_module mdbcomp.program_representation. :- import_module mdbcomp.shared_utilities. :- import_module measurements. -:- import_module profile. :- import_module read_profile. :- import_module array. diff --git a/library/diet.m b/library/diet.m index b6410cf1c..7c03c6e2b 100644 --- a/library/diet.m +++ b/library/diet.m @@ -417,7 +417,6 @@ * * ***********************************************************/ -:- import_module bool. :- import_module int. :- import_module maybe. :- import_module require. diff --git a/library/erlang_rtti_implementation.m b/library/erlang_rtti_implementation.m index e1ccda6bb..8c95a5482 100644 --- a/library/erlang_rtti_implementation.m +++ b/library/erlang_rtti_implementation.m @@ -126,7 +126,6 @@ :- import_module require. :- import_module string. :- import_module term_io. -:- import_module type_desc. % A type_info can be represented in one of three ways % For a type with arity 0 diff --git a/library/hash_table.m b/library/hash_table.m index 0208ad87f..8e3ca6066 100644 --- a/library/hash_table.m +++ b/library/hash_table.m @@ -5,33 +5,31 @@ % This file may only be copied under the terms of the GNU Library General % Public License - see the file COPYING.LIB in the Mercury distribution. %---------------------------------------------------------------------------% -% +% % File: hash_table.m. % Main author: rafe, wangp. % Stability: low. -% +% % Hash table implementation. % % This implementation requires the user to supply a predicate that -% will compute a hash value for any given key. +% computes a hash value for any given key. % -% Default hash functions are provided for ints, strings and generic -% values. +% Default hash functions are provided for ints, strings and generic values. % % The number of buckets in the hash table is always a power of 2. % -% When a user set occupancy level is achieved, the number of buckets -% in the table is doubled and the previous contents reinserted into -% the new hash table. +% When the occupancy reaches a level set by the user, we create automatically +% a new hash table with double the number of buckets, insert the contents +% of the old table into it, and use it to replace the old one. % -% CAVEAT: the user is referred to the warning at the head of array.m -% with regard to the current use of unique objects. Briefly, the -% problem is that the compiler does not yet properly understand -% unique modes, hence we fake it using non-unique modes. +% CAVEAT: The warning at the head of array.m about the use of unique objects +% also applies here. Briefly, the problem is that the compiler does not yet +% properly understand unique modes, hence we fake it using non-unique modes. % This means that care must be taken not to use an old version of a % destructively updated structure (such as a hash_table) since the % compiler will not currently detect such errors. -% +% %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% @@ -56,17 +54,17 @@ :- type hash_pred(K) == ( pred(K, int) ). :- inst hash_pred == ( pred(in, out) is det ). - % init(HashPred, N, MaxOccupancy) - % constructs a new hash table with initial size 2 ^ N that is - % doubled whenever MaxOccupancy is achieved; elements are + % init(HashPred, N, MaxOccupancy): + % + % Constructs a new hash table whose initial size is 2 ^ N, and whose + % size is doubled whenever MaxOccupancy is achieved. Elements are % indexed using HashPred. % % HashPred must compute a hash for a given key. % N must be greater than 0. % MaxOccupancy must be in (0.0, 1.0). % - % XXX Values too close to the limits may cause bad things - % to happen. + % XXX Values too close to the limits may cause bad things to happen. % :- func init(hash_pred(K), int, float) = hash_table(K, V). :- mode init(in(hash_pred), in, in) = hash_table_uo is det. @@ -106,13 +104,13 @@ % :- func num_buckets(hash_table(K, V)) = int. :- mode num_buckets(hash_table_ui) = out is det. -%:- mode num_buckets(in) = out is det. +% :- mode num_buckets(in) = out is det. % Returns the number of occupants in a hash table. % :- func num_occupants(hash_table(K, V)) = int. :- mode num_occupants(hash_table_ui) = out is det. -%:- mode num_occupants(in) = out is det. +% :- mode num_occupants(in) = out is det. % Copy the hash table. % @@ -122,9 +120,8 @@ :- func copy(hash_table(K, V)) = hash_table(K, V). :- mode copy(hash_table_ui) = hash_table_uo is det. - % Insert key-value binding into a hash table; if one is - % already there then the previous value is overwritten. - % A predicate version is also provided. + % Insert key-value binding into a hash table; if one is already there, + % then overwrite the previous value. % :- func set(hash_table(K, V), K, V) = hash_table(K, V). :- mode set(hash_table_di, in, in) = hash_table_uo is det. @@ -133,14 +130,13 @@ hash_table(K, V)::hash_table_di, hash_table(K, V)::hash_table_uo) is det. % Field update for hash tables. - % HT ^ elem(K) := V is equivalent to set(HT, K, V). + % HT ^ elem(K) := V is equivalent to set(HT, K, V). % :- func 'elem :='(K, hash_table(K, V), V) = hash_table(K, V). :- mode 'elem :='(in, hash_table_di, in) = hash_table_uo is det. - % Insert a key-value binding into a hash table. An - % exception is thrown if a binding for the key is already - % present. A predicate version is also provided. + % Insert a key-value binding into a hash table. Throw an exception + % if a binding for the key is already present. % :- func det_insert(hash_table(K, V), K, V) = hash_table(K, V). :- mode det_insert(hash_table_di, in, in) = hash_table_uo is det. @@ -148,9 +144,8 @@ :- pred det_insert(K::in, V::in, hash_table(K, V)::hash_table_di, hash_table(K, V)::hash_table_uo) is det. - % Change a key-value binding in a hash table. An - % exception is thrown if a binding for the key does not - % already exist. A predicate version is also provided. + % Change a key-value binding in a hash table. Throw an exception + % if a binding for the key does not already exist. % :- func det_update(hash_table(K, V), K, V) = hash_table(K, V). :- mode det_update(hash_table_di, in, in) = hash_table_uo is det. @@ -159,8 +154,7 @@ hash_table(K, V)::hash_table_di, hash_table(K, V)::hash_table_uo) is det. % Delete the entry for the given key, leaving the hash table - % unchanged if there is no such entry. A predicate version is also - % provided. + % unchanged if there is no such entry. % :- func delete(hash_table(K, V), K) = hash_table(K, V). :- mode delete(hash_table_di, in) = hash_table_uo is det. @@ -168,39 +162,39 @@ :- pred delete(K::in, hash_table(K, V)::hash_table_di, hash_table(K, V)::hash_table_uo) is det. - % Lookup the value associated with the given key. An exception - % is raised if there is no entry for the key. + % Lookup the value associated with the given key. Throw an exception + % if there is no entry for the key. % :- func lookup(hash_table(K, V), K) = V. :- mode lookup(hash_table_ui, in) = out is det. -%:- mode lookup(in, in) = out is det. +% :- mode lookup(in, in) = out is det. % Field access for hash tables. - % HT ^ elem(K) is equivalent to lookup(HT, K). + % HT ^ elem(K) is equivalent to lookup(HT, K). % :- func elem(K, hash_table(K, V)) = V. :- mode elem(in, hash_table_ui) = out is det. -%:- mode elem(in, in) = out is det. +% :- mode elem(in, in) = out is det. % Like lookup, but just fails if there is no entry for the key. % :- func search(hash_table(K, V), K) = V. :- mode search(hash_table_ui, in) = out is semidet. -%:- mode search(in, in, out) is semidet. +% :- mode search(in, in, out) is semidet. :- pred search(hash_table(K, V), K, V). :- mode search(hash_table_ui, in, out) is semidet. -%:- mode search(in, in, out) is semidet. +% :- mode search(in, in, out) is semidet. % Convert a hash table into an association list. % :- func to_assoc_list(hash_table(K, V)) = assoc_list(K, V). :- mode to_assoc_list(hash_table_ui) = out is det. -%:- mode to_assoc_list(in) = out is det. +% :- mode to_assoc_list(in) = out is det. % from_assoc_list(HashPred, N, MaxOccupancy, AssocList) = Table: % - % Convert an association list into a hash table. The first three + % Convert an association list into a hash table. The first three % parameters are the same as for init/3 above. % :- func from_assoc_list(hash_pred(K), int, float, assoc_list(K, V)) = @@ -248,7 +242,6 @@ :- import_module list. :- import_module pair. :- import_module string. -:- import_module type_desc. :- import_module univ. %---------------------------------------------------------------------------% @@ -277,9 +270,9 @@ :- type buckets(K, V) == array(hash_table_alist(K, V)). - % Assuming a decent hash function, there should be few collisions so each - % bucket will usually contain an empty list or a singleton. Including a - % singleton constructor therefore reduces memory consumption. + % Assuming a decent hash function, there should be few collisions, + % so each bucket will usually contain an empty list or a singleton. + % Including a singleton constructor therefore reduces memory consumption. % :- type hash_table_alist(K, V) ---> ht_nil @@ -289,19 +282,19 @@ %---------------------------------------------------------------------------% init(HashPred, N, MaxOccupancy) = HT :- - ( if N =< 0 then - throw(software_error("hash_table.init: N =< 0")) - else if N >= int.bits_per_int then - throw(software_error( - "hash_table.init: N >= int.bits_per_int")) - else if MaxOccupancy =< 0.0 then - throw(software_error( - "hash_table.init: MaxOccupancy =< 0.0")) - else - NumBuckets = 1 << N, - MaxOccupants = ceiling_to_int(float(NumBuckets) * MaxOccupancy), - Buckets = init(NumBuckets, ht_nil), - HT = ht(0, MaxOccupants, HashPred, Buckets) + ( if N =< 0 then + throw(software_error("hash_table.init: N =< 0")) + else if N >= int.bits_per_int then + throw(software_error( + "hash_table.init: N >= int.bits_per_int")) + else if MaxOccupancy =< 0.0 then + throw(software_error( + "hash_table.init: MaxOccupancy =< 0.0")) + else + NumBuckets = 1 << N, + MaxOccupants = ceiling_to_int(float(NumBuckets) * MaxOccupancy), + Buckets = init(NumBuckets, ht_nil), + HT = ht(0, MaxOccupants, HashPred, Buckets) ). new(HashPred, N, MaxOccupancy) = init(HashPred, N, MaxOccupancy). @@ -321,7 +314,7 @@ num_buckets(HT) = size(HT ^ buckets). :- func find_slot(hash_table(K, V), K) = int. :- mode find_slot(hash_table_ui, in) = out is det. -%:- mode find_slot(in, in) = out is det. +% :- mode find_slot(in, in) = out is det. :- pragma inline(find_slot/2). find_slot(HT, K) = H :- @@ -696,42 +689,27 @@ char_hash(C, H) :- %---------------------------------------------------------------------------% - % This, again, is straight off the top of my head. - % generic_hash(T, H) :- - ( if dynamic_cast(T, Int) then - + % This, again, is straight off the top of [rafe's] head. + % + ( if dynamic_cast(T, Int) then int_hash(Int, H) - - else if dynamic_cast(T, String) then - + else if dynamic_cast(T, String) then string_hash(String, H) - - else if dynamic_cast(T, Float) then - + else if dynamic_cast(T, Float) then float_hash(Float, H) - - else if dynamic_cast(T, Char) then - + else if dynamic_cast(T, Char) then char_hash(Char, H) - - else if dynamic_cast(T, Univ) then - + else if dynamic_cast(T, Univ) then generic_hash(univ_value(Univ), H) - - else if dynamic_cast_to_array(T, Array) then - + else if dynamic_cast_to_array(T, Array) then H = array.foldl( - ( func(X, HA0) = HA :- - generic_hash(X, HX), - munge(HX, HA0) = HA - ), - Array, - 0 - ) - - else - + ( func(X, HA0) = HA :- + generic_hash(X, HX), + munge(HX, HA0) = HA + ), + Array, 0) + else deconstruct(T, canonicalize, FunctorName, Arity, Args), string_hash(FunctorName, H0), munge(Arity, H0) = H1, @@ -740,9 +718,7 @@ generic_hash(T, H) :- generic_hash(U, HUA), munge(HUA, HA0) = HA ), - Args, - H1, H - ) + Args, H1, H) ). %---------------------------------------------------------------------------% diff --git a/library/io.m b/library/io.m index 73672b475..161852a9d 100644 --- a/library/io.m +++ b/library/io.m @@ -1725,7 +1725,6 @@ :- import_module enum. :- import_module exception. :- import_module int. -:- import_module map. :- import_module parser. :- import_module require. :- import_module stream.string_writer. diff --git a/library/pretty_printer.m b/library/pretty_printer.m index 308958324..0474d9012 100644 --- a/library/pretty_printer.m +++ b/library/pretty_printer.m @@ -245,7 +245,6 @@ :- import_module array. % For array_to_doc. :- import_module bool. :- import_module char. % For char_to_doc. -:- import_module deconstruct. :- import_module float. % For float_to_doc. :- import_module int. :- import_module map. diff --git a/library/private_builtin.m b/library/private_builtin.m index 00309df3b..e47c440c8 100644 --- a/library/private_builtin.m +++ b/library/private_builtin.m @@ -133,7 +133,6 @@ :- import_module char. :- import_module float. :- import_module int. -:- import_module list. :- import_module require. :- import_module string. :- import_module type_desc. diff --git a/library/string.m b/library/string.m index 5afa52fa1..2eabad9ce 100644 --- a/library/string.m +++ b/library/string.m @@ -1340,21 +1340,12 @@ :- include_module parse_runtime. :- include_module to_string. -:- import_module array. -:- import_module bitmap. -:- import_module bool. -:- import_module float. :- import_module int. -:- import_module integer. -:- import_module maybe. :- import_module pair. :- import_module require. :- import_module std_util. :- import_module string.format. :- import_module string.to_string. -:- import_module type_desc. -:- import_module univ. -:- import_module version_array. % Many routines in this module are implemented using foreign language code. diff --git a/library/string.parse_runtime.m b/library/string.parse_runtime.m index 2a22c109d..fab586d7a 100644 --- a/library/string.parse_runtime.m +++ b/library/string.parse_runtime.m @@ -81,10 +81,7 @@ :- implementation. -:- import_module bool. -:- import_module float. :- import_module int. -:- import_module integer. :- import_module maybe. :- import_module require. diff --git a/library/string.parse_util.m b/library/string.parse_util.m index 184ca34b6..69e931dfd 100644 --- a/library/string.parse_util.m +++ b/library/string.parse_util.m @@ -168,10 +168,7 @@ :- implementation. -:- import_module bool. -:- import_module float. :- import_module int. -:- import_module integer. :- import_module maybe. :- import_module require. diff --git a/library/string.to_string.m b/library/string.to_string.m index 4a1355f9f..3b60b8f13 100644 --- a/library/string.to_string.m +++ b/library/string.to_string.m @@ -44,10 +44,7 @@ :- import_module array. :- import_module bitmap. -:- import_module bool. -:- import_module float. :- import_module int. -:- import_module integer. :- import_module maybe. :- import_module pair. :- import_module std_util. diff --git a/library/table_statistics.m b/library/table_statistics.m index aa1f581b3..25a7de5c3 100644 --- a/library/table_statistics.m +++ b/library/table_statistics.m @@ -149,7 +149,6 @@ :- import_module bool. :- import_module float. :- import_module int. -:- import_module io. :- import_module require. :- import_module string. :- import_module table_builtin. diff --git a/library/term.m b/library/term.m index 1bcfc6a0f..50ba8400f 100644 --- a/library/term.m +++ b/library/term.m @@ -714,14 +714,8 @@ :- implementation. -:- import_module array. -:- import_module bitmap. -:- import_module construct. -:- import_module deconstruct. :- import_module int. :- import_module require. -:- import_module string. -:- import_module version_array. %---------------------------------------------------------------------------% diff --git a/library/term_io.m b/library/term_io.m index 4b01ad925..de7ff91a6 100644 --- a/library/term_io.m +++ b/library/term_io.m @@ -250,13 +250,11 @@ :- implementation. :- import_module bool. -:- import_module char. :- import_module int. :- import_module integer. :- import_module lexer. :- import_module list. :- import_module parser. -:- import_module require. :- import_module string. :- import_module stream.string_writer. diff --git a/library/term_to_xml.m b/library/term_to_xml.m index 5469fc0a4..8b475f054 100644 --- a/library/term_to_xml.m +++ b/library/term_to_xml.m @@ -461,7 +461,6 @@ :- import_module bool. :- import_module char. :- import_module construct. -:- import_module exception. :- import_module int. :- import_module map. :- import_module require. diff --git a/library/test_bitset.m b/library/test_bitset.m index 5e15b4119..758431c9b 100644 --- a/library/test_bitset.m +++ b/library/test_bitset.m @@ -146,8 +146,6 @@ :- import_module bool. :- import_module exception. -:- import_module int. -:- import_module list. :- import_module maybe. :- import_module pair. :- import_module require. diff --git a/library/thread.barrier.m b/library/thread.barrier.m index 6dca936f7..017909371 100644 --- a/library/thread.barrier.m +++ b/library/thread.barrier.m @@ -17,9 +17,9 @@ % be suspended at until all the other threads (of N) reach the same % position. % -% Barriers are represented by calls to barrier/3 (defined below). Different +% Barriers are represented by calls to barrier/3 (defined below). Different % code locations can belong to the same conceptual barrier using values of -% type barrier. The same code location can also be used by multiple +% type barrier. The same code location can also be used by multiple % barriers by supplying different values. % %---------------------------------------------------------------------------% @@ -40,7 +40,7 @@ % wait(Barrier, !IO) % - % Indicate that the current thread has reached the barrier. Throws a + % Indicate that the current thread has reached the barrier. Throws a % software_error/1 exception if this barrier has been used by more than % N threads. % @@ -49,7 +49,7 @@ % release_barrier(Barrier, !IO) % % Release all the threads waiting at the barrier regardless of whether - % or not N threads have arrived at the barrier. This can be called by + % or not N threads have arrived at the barrier. This can be called by % any thread, it does not have to be a thread that would normally call % wait/3. % @@ -69,9 +69,7 @@ :- import_module int. :- import_module require. -:- import_module string. :- import_module thread.mvar. -:- import_module unit. %---------------------------------------------------------------------------% @@ -85,7 +83,7 @@ ). % We use this type to say why execution may proceed after reaching the - % barrier. If it is because the counter reached zero or because + % barrier. If it is because the counter reached zero or because % release/3 was called. % :- type why_can_we_go @@ -143,7 +141,7 @@ release(barrier(WaitingOn, Go), !IO) :- % We must set WaitingOn to zero so that the StillWaitingFor = 0 branch % above is not executed more than once, if it is it will block when it - % tries to write a value to Go as Go already has a value. Instead we + % tries to write a value to Go as Go already has a value. Instead we % set it to zero, which means that StillWaitingOn will be -1, we use a % special value of can_go_release_called for Go so that this branch does % not raise an error. diff --git a/library/thread.m b/library/thread.m index e8c3efe72..1e1748dcd 100644 --- a/library/thread.m +++ b/library/thread.m @@ -100,7 +100,6 @@ :- import_module bool. :- import_module require. -:- import_module string. :- pragma foreign_decl("C", " #ifndef MR_HIGHLEVEL_CODE diff --git a/library/thread.mvar.m b/library/thread.mvar.m index f9ff465c4..47f8c3004 100644 --- a/library/thread.mvar.m +++ b/library/thread.mvar.m @@ -79,7 +79,6 @@ :- implementation. -:- import_module bool. :- import_module mutvar. :- import_module thread.semaphore. diff --git a/library/tree_bitset.m b/library/tree_bitset.m index fc4f3f3e1..db699490f 100644 --- a/library/tree_bitset.m +++ b/library/tree_bitset.m @@ -434,7 +434,6 @@ :- implementation. :- import_module int. -:- import_module list. :- import_module require. % These are needed only for integrity checking. diff --git a/library/version_hash_table.m b/library/version_hash_table.m index eaf1d1efc..aefdcd66a 100644 --- a/library/version_hash_table.m +++ b/library/version_hash_table.m @@ -220,7 +220,6 @@ :- import_module pair. :- import_module require. :- import_module string. -:- import_module type_desc. :- import_module unit. :- import_module univ. :- import_module version_array. diff --git a/mdbcomp/builtin_modules.m b/mdbcomp/builtin_modules.m index 7810eddb2..055ba6aeb 100644 --- a/mdbcomp/builtin_modules.m +++ b/mdbcomp/builtin_modules.m @@ -149,10 +149,7 @@ :- implementation. -:- import_module int. :- import_module library. -:- import_module list. -:- import_module string. %-----------------------------------------------------------------------------% diff --git a/mdbcomp/feedback.m b/mdbcomp/feedback.m index 0e6262521..023c3b776 100644 --- a/mdbcomp/feedback.m +++ b/mdbcomp/feedback.m @@ -220,7 +220,6 @@ :- implementation. :- import_module exception. -:- import_module map. :- import_module require. :- import_module string. :- import_module unit. diff --git a/mdbcomp/mdbcomp.goal_path.m b/mdbcomp/mdbcomp.goal_path.m index 863f7f28b..191b0fc02 100644 --- a/mdbcomp/mdbcomp.goal_path.m +++ b/mdbcomp/mdbcomp.goal_path.m @@ -331,7 +331,6 @@ :- implementation. :- import_module assoc_list. -:- import_module cord. :- import_module int. :- import_module list. :- import_module pair. diff --git a/mdbcomp/program_representation.m b/mdbcomp/program_representation.m index 30425b06b..03e4f9aa6 100644 --- a/mdbcomp/program_representation.m +++ b/mdbcomp/program_representation.m @@ -693,7 +693,6 @@ :- import_module mdbcomp.builtin_modules. :- import_module int. -:- import_module map. :- import_module require. :- import_module string. diff --git a/mdbcomp/sym_name.m b/mdbcomp/sym_name.m index de7e94996..af461dcc3 100644 --- a/mdbcomp/sym_name.m +++ b/mdbcomp/sym_name.m @@ -194,8 +194,6 @@ :- implementation. :- import_module int. -:- import_module library. -:- import_module list. :- import_module require. :- import_module string. diff --git a/mdbcomp/trace_counts.m b/mdbcomp/trace_counts.m index f63e2db89..f3c18e7fa 100644 --- a/mdbcomp/trace_counts.m +++ b/mdbcomp/trace_counts.m @@ -188,7 +188,6 @@ :- import_module exception. :- import_module int. -:- import_module io. :- import_module lexer. :- import_module require. :- import_module string. diff --git a/mfilterjavac/mfilterjavac.m b/mfilterjavac/mfilterjavac.m index 70f3fcc1b..d037bc541 100644 --- a/mfilterjavac/mfilterjavac.m +++ b/mfilterjavac/mfilterjavac.m @@ -10,11 +10,11 @@ % Author: pbone % % This program processes the output of the Java compiler when compiling Java -% code generated by the Mercury compiler. It translates the error contexts +% code generated by the Mercury compiler. It translates the error contexts % reported by the Java compiler into the corresponding error contexts in the -% Mercury source file. This is done by looking for special comments -% inserted into the generated Java code by the Mercury compiler. (See -% compiler/mlds_to_java.m for details.) +% Mercury source file. This is done by looking for special comments inserted +% into the generated Java code by the Mercury compiler. +% (See compiler/mlds_to_java.m for details.) % %-----------------------------------------------------------------------------% @@ -37,7 +37,6 @@ :- import_module list. :- import_module map. :- import_module maybe. -:- import_module require. :- import_module string. %-----------------------------------------------------------------------------% diff --git a/tests/invalid/Mercury.options b/tests/invalid/Mercury.options index 79c42f018..a2409808d 100644 --- a/tests/invalid/Mercury.options +++ b/tests/invalid/Mercury.options @@ -33,7 +33,7 @@ MCFLAGS-ii_parent = --no-intermodule-optimization MCFLAGS-ii_parent.ii_child = --no-intermodule-optimization MCFLAGS-illtyped_compare = --no-intermodule-optimization \ --verbose-error-messages -MCFLAGS-import_in_parent = --no-intermodule-optimization +MCFLAGS-import_in_parent = --no-intermodule-optimization --warn-unused-imports MCFLAGS-import_in_parent.sub = --no-intermodule-optimization MCFLAGS-imported_mode = --infer-all --no-intermodule-optimization MCFLAGS-impure_method_impl = --no-intermodule-optimization \ diff --git a/tests/invalid/any_passed_as_ground.err_exp b/tests/invalid/any_passed_as_ground.err_exp index 5f22753e6..e99b14709 100644 --- a/tests/invalid/any_passed_as_ground.err_exp +++ b/tests/invalid/any_passed_as_ground.err_exp @@ -1,13 +1,13 @@ -any_passed_as_ground.m:036: In clause for `main(di, uo)': -any_passed_as_ground.m:036: in call to predicate `list.member'/2: -any_passed_as_ground.m:036: mode error: arguments `TypeInfo_15, V_10, Xs' -any_passed_as_ground.m:036: have the following insts: -any_passed_as_ground.m:036: unique(private_builtin.type_info(unique(), unique(), unique())), -any_passed_as_ground.m:036: free, -any_passed_as_ground.m:036: any -any_passed_as_ground.m:036: which does not match any of the modes for -any_passed_as_ground.m:036: predicate `list.member'/2. +any_passed_as_ground.m:029: In clause for `main(di, uo)': +any_passed_as_ground.m:029: in call to predicate `list.member'/2: +any_passed_as_ground.m:029: mode error: arguments `TypeInfo_15, V_10, Xs' +any_passed_as_ground.m:029: have the following insts: +any_passed_as_ground.m:029: unique(private_builtin.type_info(unique(), unique(), unique())), +any_passed_as_ground.m:029: free, +any_passed_as_ground.m:029: any +any_passed_as_ground.m:029: which does not match any of the modes for +any_passed_as_ground.m:029: predicate `list.member'/2. For more information, recompile with `-E'. diff --git a/tests/invalid/any_passed_as_ground.err_exp2 b/tests/invalid/any_passed_as_ground.err_exp2 index d5d070081..ff85031dd 100644 --- a/tests/invalid/any_passed_as_ground.err_exp2 +++ b/tests/invalid/any_passed_as_ground.err_exp2 @@ -1,13 +1,13 @@ -any_passed_as_ground.m:030: In clause for `main(di, uo)': -any_passed_as_ground.m:030: in call to predicate `list.member'/2: -any_passed_as_ground.m:030: mode error: arguments `TypeInfo_12, V_10, Xs' -any_passed_as_ground.m:030: have the following insts: -any_passed_as_ground.m:030: bound(private_builtin.type_info(bound(), bound(), bound())), -any_passed_as_ground.m:030: free, -any_passed_as_ground.m:030: any -any_passed_as_ground.m:030: which does not match any of the modes for -any_passed_as_ground.m:030: predicate `list.member'/2. +any_passed_as_ground.m:029: In clause for `main(di, uo)': +any_passed_as_ground.m:029: in call to predicate `list.member'/2: +any_passed_as_ground.m:029: mode error: arguments `TypeInfo_12, V_10, Xs' +any_passed_as_ground.m:029: have the following insts: +any_passed_as_ground.m:029: bound(private_builtin.type_info(bound(), bound(), bound())), +any_passed_as_ground.m:029: free, +any_passed_as_ground.m:029: any +any_passed_as_ground.m:029: which does not match any of the modes for +any_passed_as_ground.m:029: predicate `list.member'/2. For more information, recompile with `-E'. diff --git a/tests/invalid/any_passed_as_ground.m b/tests/invalid/any_passed_as_ground.m index 1cd64e04b..0c82ad3bf 100644 --- a/tests/invalid/any_passed_as_ground.m +++ b/tests/invalid/any_passed_as_ground.m @@ -19,7 +19,6 @@ :- implementation. -:- import_module int. :- import_module list. :- import_module pair. diff --git a/tests/invalid/any_to_ground_in_ite_cond.err_exp b/tests/invalid/any_to_ground_in_ite_cond.err_exp index f2d0014fc..0794ac0ea 100644 --- a/tests/invalid/any_to_ground_in_ite_cond.err_exp +++ b/tests/invalid/any_to_ground_in_ite_cond.err_exp @@ -1,9 +1,9 @@ -any_to_ground_in_ite_cond.m:031: In clause for `main(di, uo)': -any_to_ground_in_ite_cond.m:031: in argument 1 of call to predicate -any_to_ground_in_ite_cond.m:031: `any_to_ground_in_ite_cond.p'/1: -any_to_ground_in_ite_cond.m:031: scope error: attempt to bind a non-local -any_to_ground_in_ite_cond.m:031: variable inside the condition of an -any_to_ground_in_ite_cond.m:031: if-then-else. -any_to_ground_in_ite_cond.m:031: Variable `X' has instantiatedness `any', -any_to_ground_in_ite_cond.m:031: expected instantiatedness was `ground'. +any_to_ground_in_ite_cond.m:027: In clause for `main(di, uo)': +any_to_ground_in_ite_cond.m:027: in argument 1 of call to predicate +any_to_ground_in_ite_cond.m:027: `any_to_ground_in_ite_cond.p'/1: +any_to_ground_in_ite_cond.m:027: scope error: attempt to bind a non-local +any_to_ground_in_ite_cond.m:027: variable inside the condition of an +any_to_ground_in_ite_cond.m:027: if-then-else. +any_to_ground_in_ite_cond.m:027: Variable `X' has instantiatedness `any', +any_to_ground_in_ite_cond.m:027: expected instantiatedness was `ground'. For more information, recompile with `-E'. diff --git a/tests/invalid/any_to_ground_in_ite_cond.m b/tests/invalid/any_to_ground_in_ite_cond.m index 98de896f9..db375c408 100644 --- a/tests/invalid/any_to_ground_in_ite_cond.m +++ b/tests/invalid/any_to_ground_in_ite_cond.m @@ -19,10 +19,6 @@ :- implementation. -:- import_module int. -:- import_module list. -:- import_module std_util. - :- solver type st where representation is int. main(!IO) :- diff --git a/tests/invalid/any_to_ground_in_ite_cond_nomax.err_exp b/tests/invalid/any_to_ground_in_ite_cond_nomax.err_exp index 6136a71f2..1aa765cd7 100644 --- a/tests/invalid/any_to_ground_in_ite_cond_nomax.err_exp +++ b/tests/invalid/any_to_ground_in_ite_cond_nomax.err_exp @@ -1,6 +1,6 @@ -any_to_ground_in_ite_cond_nomax.m:036: In clause for `main(di, uo)': -any_to_ground_in_ite_cond_nomax.m:036: in argument 1 of call to predicate `any_to_ground_in_ite_cond_nomax.p'/1: -any_to_ground_in_ite_cond_nomax.m:036: scope error: attempt to bind a non-local variable inside the condition of an if-then-else. -any_to_ground_in_ite_cond_nomax.m:036: Variable `X' has instantiatedness `any', -any_to_ground_in_ite_cond_nomax.m:036: expected instantiatedness was `ground'. +any_to_ground_in_ite_cond_nomax.m:032: In clause for `main(di, uo)': +any_to_ground_in_ite_cond_nomax.m:032: in argument 1 of call to predicate `any_to_ground_in_ite_cond_nomax.p'/1: +any_to_ground_in_ite_cond_nomax.m:032: scope error: attempt to bind a non-local variable inside the condition of an if-then-else. +any_to_ground_in_ite_cond_nomax.m:032: Variable `X' has instantiatedness `any', +any_to_ground_in_ite_cond_nomax.m:032: expected instantiatedness was `ground'. For more information, recompile with `-E'. diff --git a/tests/invalid/any_to_ground_in_ite_cond_nomax.m b/tests/invalid/any_to_ground_in_ite_cond_nomax.m index 6f2e4624c..fd3b5987d 100644 --- a/tests/invalid/any_to_ground_in_ite_cond_nomax.m +++ b/tests/invalid/any_to_ground_in_ite_cond_nomax.m @@ -22,10 +22,6 @@ :- implementation. -:- import_module int. -:- import_module list. -:- import_module std_util. - :- solver type st where representation is int. %---------------------------------------------------------------------------% diff --git a/tests/invalid/anys_in_negated_contexts.err_exp b/tests/invalid/anys_in_negated_contexts.err_exp index b363c7442..b97c13903 100644 --- a/tests/invalid/anys_in_negated_contexts.err_exp +++ b/tests/invalid/anys_in_negated_contexts.err_exp @@ -1,30 +1,30 @@ -anys_in_negated_contexts.m:041: In clause for `bad_if_then_else1(ia, out)': -anys_in_negated_contexts.m:041: purity error: if-then-else should be inside a -anys_in_negated_contexts.m:041: promise_purity scope because non-local -anys_in_negated_contexts.m:041: variable `X' has inst `any' and appears in -anys_in_negated_contexts.m:041: the condition. -anys_in_negated_contexts.m:059: In clause for `bad_negation1(ia)': -anys_in_negated_contexts.m:059: purity error: negation should be inside a -anys_in_negated_contexts.m:059: promise_purity scope because non-local -anys_in_negated_contexts.m:059: variable `X' has inst `any' and appears in -anys_in_negated_contexts.m:059: the body. -anys_in_negated_contexts.m:082: In clause for `bad_lambda(in)': -anys_in_negated_contexts.m:082: mode error in conjunction. The next 2 error -anys_in_negated_contexts.m:082: messages indicate possible causes of this -anys_in_negated_contexts.m:082: error. -anys_in_negated_contexts.m:081: In clause for `bad_lambda(in)': -anys_in_negated_contexts.m:081: purity error: lambda is `ground' but contains -anys_in_negated_contexts.m:081: the following non-local variables whose insts -anys_in_negated_contexts.m:081: contain `any': Y. -anys_in_negated_contexts.m:081: Predicate expressions with inst `any' can be -anys_in_negated_contexts.m:081: written `any_pred(Args) is det :- ...'. -anys_in_negated_contexts.m:081: Function expressions with inst `any' can be -anys_in_negated_contexts.m:081: written -anys_in_negated_contexts.m:081: `any_func(Args) = Result is det :- ...'. -anys_in_negated_contexts.m:082: In clause for `bad_lambda(in)': -anys_in_negated_contexts.m:082: in argument 1 (i.e. the predicate term) of -anys_in_negated_contexts.m:082: higher-order predicate call: -anys_in_negated_contexts.m:082: mode error: variable `P' has instantiatedness -anys_in_negated_contexts.m:082: `free', -anys_in_negated_contexts.m:082: expecting higher-order pred inst (of arity -anys_in_negated_contexts.m:082: 1). +anys_in_negated_contexts.m:039: In clause for `bad_if_then_else1(ia, out)': +anys_in_negated_contexts.m:039: purity error: if-then-else should be inside a +anys_in_negated_contexts.m:039: promise_purity scope because non-local +anys_in_negated_contexts.m:039: variable `X' has inst `any' and appears in +anys_in_negated_contexts.m:039: the condition. +anys_in_negated_contexts.m:057: In clause for `bad_negation1(ia)': +anys_in_negated_contexts.m:057: purity error: negation should be inside a +anys_in_negated_contexts.m:057: promise_purity scope because non-local +anys_in_negated_contexts.m:057: variable `X' has inst `any' and appears in +anys_in_negated_contexts.m:057: the body. +anys_in_negated_contexts.m:080: In clause for `bad_lambda(in)': +anys_in_negated_contexts.m:080: mode error in conjunction. The next 2 error +anys_in_negated_contexts.m:080: messages indicate possible causes of this +anys_in_negated_contexts.m:080: error. +anys_in_negated_contexts.m:079: In clause for `bad_lambda(in)': +anys_in_negated_contexts.m:079: purity error: lambda is `ground' but contains +anys_in_negated_contexts.m:079: the following non-local variables whose insts +anys_in_negated_contexts.m:079: contain `any': Y. +anys_in_negated_contexts.m:079: Predicate expressions with inst `any' can be +anys_in_negated_contexts.m:079: written `any_pred(Args) is det :- ...'. +anys_in_negated_contexts.m:079: Function expressions with inst `any' can be +anys_in_negated_contexts.m:079: written +anys_in_negated_contexts.m:079: `any_func(Args) = Result is det :- ...'. +anys_in_negated_contexts.m:080: In clause for `bad_lambda(in)': +anys_in_negated_contexts.m:080: in argument 1 (i.e. the predicate term) of +anys_in_negated_contexts.m:080: higher-order predicate call: +anys_in_negated_contexts.m:080: mode error: variable `P' has instantiatedness +anys_in_negated_contexts.m:080: `free', +anys_in_negated_contexts.m:080: expecting higher-order pred inst (of arity +anys_in_negated_contexts.m:080: 1). diff --git a/tests/invalid/anys_in_negated_contexts.m b/tests/invalid/anys_in_negated_contexts.m index d3e7540f6..e16837efa 100644 --- a/tests/invalid/anys_in_negated_contexts.m +++ b/tests/invalid/anys_in_negated_contexts.m @@ -14,8 +14,6 @@ :- implementation. -:- import_module std_util. - :- pred good_if_then_else(T::ia, int::out) is det. good_if_then_else(X, Y) :- diff --git a/tests/invalid/bind_var_errors.err_exp b/tests/invalid/bind_var_errors.err_exp index ce8c14e71..e7b74653f 100644 --- a/tests/invalid/bind_var_errors.err_exp +++ b/tests/invalid/bind_var_errors.err_exp @@ -1,28 +1,28 @@ -bind_var_errors.m:037: In clause for `bind_var_in_negation': -bind_var_errors.m:037: scope error: attempt to bind a non-local variable -bind_var_errors.m:037: inside a negation. -bind_var_errors.m:037: Variable `X' has instantiatedness `free', -bind_var_errors.m:037: expected instantiatedness was `unique(42)'. -bind_var_errors.m:043: In clause for `bind_var_in_ite_cond(in)': -bind_var_errors.m:043: scope error: attempt to bind a non-local variable -bind_var_errors.m:043: inside the condition of an if-then-else. -bind_var_errors.m:043: Variable `Y' has instantiatedness `free', -bind_var_errors.m:043: expected instantiatedness was `unique(42)'. -bind_var_errors.m:052: In clause for `bind_var_in_lambda': -bind_var_errors.m:052: in argument 1 (i.e. the predicate term) of -bind_var_errors.m:052: higher-order predicate call: -bind_var_errors.m:052: mode error: variable `Y' has instantiatedness `free', -bind_var_errors.m:052: expected instantiatedness for non-local variables of -bind_var_errors.m:052: lambda goals is `ground'. -bind_var_errors.m:057: In clause for `share_var_in_lambda(di)': -bind_var_errors.m:057: in argument 1 of call to predicate -bind_var_errors.m:057: `bind_var_errors.destroy'/1: -bind_var_errors.m:057: mode error: variable `X' has instantiatedness -bind_var_errors.m:057: `ground', -bind_var_errors.m:057: expected instantiatedness was `unique'. -bind_var_errors.m:064: In clause for `clobber_var_in_lambda(di)': -bind_var_errors.m:064: in argument 1 of call to predicate -bind_var_errors.m:064: `bind_var_errors.destroy'/1: -bind_var_errors.m:064: unique-mode error: the called procedure would clobber -bind_var_errors.m:064: its argument, but variable `X' is still live. +bind_var_errors.m:035: In clause for `bind_var_in_negation': +bind_var_errors.m:035: scope error: attempt to bind a non-local variable +bind_var_errors.m:035: inside a negation. +bind_var_errors.m:035: Variable `X' has instantiatedness `free', +bind_var_errors.m:035: expected instantiatedness was `unique(42)'. +bind_var_errors.m:041: In clause for `bind_var_in_ite_cond(in)': +bind_var_errors.m:041: scope error: attempt to bind a non-local variable +bind_var_errors.m:041: inside the condition of an if-then-else. +bind_var_errors.m:041: Variable `Y' has instantiatedness `free', +bind_var_errors.m:041: expected instantiatedness was `unique(42)'. +bind_var_errors.m:050: In clause for `bind_var_in_lambda': +bind_var_errors.m:050: in argument 1 (i.e. the predicate term) of +bind_var_errors.m:050: higher-order predicate call: +bind_var_errors.m:050: mode error: variable `Y' has instantiatedness `free', +bind_var_errors.m:050: expected instantiatedness for non-local variables of +bind_var_errors.m:050: lambda goals is `ground'. +bind_var_errors.m:055: In clause for `share_var_in_lambda(di)': +bind_var_errors.m:055: in argument 1 of call to predicate +bind_var_errors.m:055: `bind_var_errors.destroy'/1: +bind_var_errors.m:055: mode error: variable `X' has instantiatedness +bind_var_errors.m:055: `ground', +bind_var_errors.m:055: expected instantiatedness was `unique'. +bind_var_errors.m:062: In clause for `clobber_var_in_lambda(di)': +bind_var_errors.m:062: in argument 1 of call to predicate +bind_var_errors.m:062: `bind_var_errors.destroy'/1: +bind_var_errors.m:062: unique-mode error: the called procedure would clobber +bind_var_errors.m:062: its argument, but variable `X' is still live. For more information, recompile with `-E'. diff --git a/tests/invalid/bind_var_errors.m b/tests/invalid/bind_var_errors.m index b28986a32..a82cb294a 100644 --- a/tests/invalid/bind_var_errors.m +++ b/tests/invalid/bind_var_errors.m @@ -5,8 +5,6 @@ :- module bind_var_errors. :- interface. -:- import_module int. - :- pred bind_var_in_negation is semidet. :- pred bind_var_in_ite_cond(int :: in) is semidet. diff --git a/tests/invalid/conflicting_tabling_pragmas.m b/tests/invalid/conflicting_tabling_pragmas.m index 9e286c349..d7de39030 100644 --- a/tests/invalid/conflicting_tabling_pragmas.m +++ b/tests/invalid/conflicting_tabling_pragmas.m @@ -6,12 +6,12 @@ :- interface. -:- import_module int. - :- func fac(int) = int. :- implementation. +:- import_module int. + :- pragma memo(fac/1). :- pragma loop_check(fac/1). diff --git a/tests/invalid/foreign_purity_mismatch.err_exp b/tests/invalid/foreign_purity_mismatch.err_exp index 923cd7cd3..92a214bcb 100644 --- a/tests/invalid/foreign_purity_mismatch.err_exp +++ b/tests/invalid/foreign_purity_mismatch.err_exp @@ -1,35 +1,35 @@ -foreign_purity_mismatch.m:010: In predicate `pure_with_impure'/1: -foreign_purity_mismatch.m:010: purity error: predicate is impure. -foreign_purity_mismatch.m:010: It must be declared `impure' or promised pure. -foreign_purity_mismatch.m:011: In predicate `pure_with_semipure'/1: -foreign_purity_mismatch.m:011: purity error: predicate is semipure. -foreign_purity_mismatch.m:011: It must be declared `semipure' or promised -foreign_purity_mismatch.m:011: pure. -foreign_purity_mismatch.m:013: In predicate `semipure_with_impure'/1: -foreign_purity_mismatch.m:013: purity error: predicate is impure. -foreign_purity_mismatch.m:013: It must be declared `impure' or promised -foreign_purity_mismatch.m:013: semipure. -foreign_purity_mismatch.m:024: Error: foreign clause for predicate -foreign_purity_mismatch.m:024: `foreign_purity_mismatch.pure_with_impure'/1 -foreign_purity_mismatch.m:024: has purity impure but that predicate has been -foreign_purity_mismatch.m:024: declared pure. -foreign_purity_mismatch.m:031: Error: foreign clause for predicate -foreign_purity_mismatch.m:031: `foreign_purity_mismatch.pure_with_semipure'/1 -foreign_purity_mismatch.m:031: has purity semipure but that predicate has -foreign_purity_mismatch.m:031: been declared pure. -foreign_purity_mismatch.m:038: Error: foreign clause for predicate -foreign_purity_mismatch.m:038: `foreign_purity_mismatch.semipure_with_impure'/1 -foreign_purity_mismatch.m:038: has purity impure but that predicate has been -foreign_purity_mismatch.m:038: declared semipure. -foreign_purity_mismatch.m:045: Error: foreign clause for predicate -foreign_purity_mismatch.m:045: `foreign_purity_mismatch.semipure_with_pure'/1 -foreign_purity_mismatch.m:045: has purity pure but that predicate has been -foreign_purity_mismatch.m:045: declared semipure. -foreign_purity_mismatch.m:052: Error: foreign clause for predicate -foreign_purity_mismatch.m:052: `foreign_purity_mismatch.impure_with_pure'/1 -foreign_purity_mismatch.m:052: has purity pure but that predicate has been -foreign_purity_mismatch.m:052: declared impure. -foreign_purity_mismatch.m:059: Error: foreign clause for predicate -foreign_purity_mismatch.m:059: `foreign_purity_mismatch.impure_with_semipure'/1 -foreign_purity_mismatch.m:059: has purity semipure but that predicate has -foreign_purity_mismatch.m:059: been declared impure. +foreign_purity_mismatch.m:008: In predicate `pure_with_impure'/1: +foreign_purity_mismatch.m:008: purity error: predicate is impure. +foreign_purity_mismatch.m:008: It must be declared `impure' or promised pure. +foreign_purity_mismatch.m:009: In predicate `pure_with_semipure'/1: +foreign_purity_mismatch.m:009: purity error: predicate is semipure. +foreign_purity_mismatch.m:009: It must be declared `semipure' or promised +foreign_purity_mismatch.m:009: pure. +foreign_purity_mismatch.m:011: In predicate `semipure_with_impure'/1: +foreign_purity_mismatch.m:011: purity error: predicate is impure. +foreign_purity_mismatch.m:011: It must be declared `impure' or promised +foreign_purity_mismatch.m:011: semipure. +foreign_purity_mismatch.m:022: Error: foreign clause for predicate +foreign_purity_mismatch.m:022: `foreign_purity_mismatch.pure_with_impure'/1 +foreign_purity_mismatch.m:022: has purity impure but that predicate has been +foreign_purity_mismatch.m:022: declared pure. +foreign_purity_mismatch.m:029: Error: foreign clause for predicate +foreign_purity_mismatch.m:029: `foreign_purity_mismatch.pure_with_semipure'/1 +foreign_purity_mismatch.m:029: has purity semipure but that predicate has +foreign_purity_mismatch.m:029: been declared pure. +foreign_purity_mismatch.m:036: Error: foreign clause for predicate +foreign_purity_mismatch.m:036: `foreign_purity_mismatch.semipure_with_impure'/1 +foreign_purity_mismatch.m:036: has purity impure but that predicate has been +foreign_purity_mismatch.m:036: declared semipure. +foreign_purity_mismatch.m:043: Error: foreign clause for predicate +foreign_purity_mismatch.m:043: `foreign_purity_mismatch.semipure_with_pure'/1 +foreign_purity_mismatch.m:043: has purity pure but that predicate has been +foreign_purity_mismatch.m:043: declared semipure. +foreign_purity_mismatch.m:050: Error: foreign clause for predicate +foreign_purity_mismatch.m:050: `foreign_purity_mismatch.impure_with_pure'/1 +foreign_purity_mismatch.m:050: has purity pure but that predicate has been +foreign_purity_mismatch.m:050: declared impure. +foreign_purity_mismatch.m:057: Error: foreign clause for predicate +foreign_purity_mismatch.m:057: `foreign_purity_mismatch.impure_with_semipure'/1 +foreign_purity_mismatch.m:057: has purity semipure but that predicate has +foreign_purity_mismatch.m:057: been declared impure. diff --git a/tests/invalid/foreign_purity_mismatch.m b/tests/invalid/foreign_purity_mismatch.m index 5cd2efa52..1b6cf3664 100644 --- a/tests/invalid/foreign_purity_mismatch.m +++ b/tests/invalid/foreign_purity_mismatch.m @@ -5,8 +5,6 @@ :- module foreign_purity_mismatch. :- interface. -:- import_module string. - :- pred pure_with_impure(string::in) is det. :- pred pure_with_semipure(string::in) is det. diff --git a/tests/invalid/func_errors.err_exp b/tests/invalid/func_errors.err_exp index a3582a78a..5ebf4869c 100644 --- a/tests/invalid/func_errors.err_exp +++ b/tests/invalid/func_errors.err_exp @@ -1,10 +1,10 @@ +func_errors.m:011: Error: function arguments have modes, but function result +func_errors.m:011: does not. +func_errors.m:011: Error: some but not all arguments have modes. +func_errors.m:011: The argument without a mode is the second. func_errors.m:012: Error: function arguments have modes, but function result func_errors.m:012: does not. -func_errors.m:012: Error: some but not all arguments have modes. -func_errors.m:012: The argument without a mode is the second. -func_errors.m:013: Error: function arguments have modes, but function result -func_errors.m:013: does not. -func_errors.m:014: Error: function result has mode, but function arguments do -func_errors.m:014: not. -func_errors.m:020: Error: some but not all arguments have modes. -func_errors.m:020: The arguments without modes are the second and third. +func_errors.m:013: Error: function result has mode, but function arguments do +func_errors.m:013: not. +func_errors.m:019: Error: some but not all arguments have modes. +func_errors.m:019: The arguments without modes are the second and third. diff --git a/tests/invalid/func_errors.m b/tests/invalid/func_errors.m index 0ecab1a57..dedeadf4a 100644 --- a/tests/invalid/func_errors.m +++ b/tests/invalid/func_errors.m @@ -5,7 +5,6 @@ :- module func_errors. :- interface. -:- import_module int. % it is an error to only declare some of the modes @@ -20,6 +19,7 @@ :- pred q(int::in, int, int) is semidet. :- implementation. +:- import_module int. % foo(X, Y) = X + Y :- X > 0. % bar(X, Y) = X + Y :- X > 0. diff --git a/tests/invalid/hawkins_mm_fail_reset.err_exp b/tests/invalid/hawkins_mm_fail_reset.err_exp index 2d64491aa..6087042e2 100644 --- a/tests/invalid/hawkins_mm_fail_reset.err_exp +++ b/tests/invalid/hawkins_mm_fail_reset.err_exp @@ -2,14 +2,14 @@ hawkins_mm_fail_reset.m:024: In `entry'(out): hawkins_mm_fail_reset.m:024: warning: determinism declaration could be hawkins_mm_fail_reset.m:024: tighter. hawkins_mm_fail_reset.m:024: Declared `nondet', inferred `failure'. -hawkins_mm_fail_reset.m:032: Error: `:- pragma minimal_model' declaration not -hawkins_mm_fail_reset.m:032: allowed for procedure with determinism -hawkins_mm_fail_reset.m:032: `failure'. -hawkins_mm_fail_reset.m:035: Warning: this disjunct will never have any -hawkins_mm_fail_reset.m:035: solutions. -hawkins_mm_fail_reset.m:038: Warning: this disjunct will never have any -hawkins_mm_fail_reset.m:038: solutions. -hawkins_mm_fail_reset.m:041: Error: `:- pragma minimal_model' declaration not -hawkins_mm_fail_reset.m:041: allowed for procedure with determinism -hawkins_mm_fail_reset.m:041: `failure'. +hawkins_mm_fail_reset.m:031: Error: `:- pragma minimal_model' declaration not +hawkins_mm_fail_reset.m:031: allowed for procedure with determinism +hawkins_mm_fail_reset.m:031: `failure'. +hawkins_mm_fail_reset.m:034: Warning: this disjunct will never have any +hawkins_mm_fail_reset.m:034: solutions. +hawkins_mm_fail_reset.m:037: Warning: this disjunct will never have any +hawkins_mm_fail_reset.m:037: solutions. +hawkins_mm_fail_reset.m:040: Error: `:- pragma minimal_model' declaration not +hawkins_mm_fail_reset.m:040: allowed for procedure with determinism +hawkins_mm_fail_reset.m:040: `failure'. For more information, recompile with `-E'. diff --git a/tests/invalid/hawkins_mm_fail_reset.m b/tests/invalid/hawkins_mm_fail_reset.m index 166c09d2c..6184fdef4 100644 --- a/tests/invalid/hawkins_mm_fail_reset.m +++ b/tests/invalid/hawkins_mm_fail_reset.m @@ -24,7 +24,6 @@ :- pred entry(int::out) is nondet. :- implementation. -:- import_module int. entry(0) :- pred1(_). diff --git a/tests/invalid/import_in_parent.err_exp b/tests/invalid/import_in_parent.err_exp index 8c044ae0c..95c0c0b06 100644 --- a/tests/invalid/import_in_parent.err_exp +++ b/tests/invalid/import_in_parent.err_exp @@ -1,2 +1,6 @@ +import_in_parent.m:009: In module `import_in_parent': +import_in_parent.m:009: warning: module `bool' has a `:- import_module' +import_in_parent.m:009: declaration in the interface, but is not used in the +import_in_parent.m:009: interface. import_in_parent.m:027: In clause for predicate `foo'/1: import_in_parent.m:027: error: undefined predicate `bool.foo'/1. diff --git a/tests/invalid/invalid_int.err_exp b/tests/invalid/invalid_int.err_exp index 12a37b7cd..264ec0bc5 100644 --- a/tests/invalid/invalid_int.err_exp +++ b/tests/invalid/invalid_int.err_exp @@ -1,18 +1,18 @@ +invalid_int.m:017: Error: integer literal is too big +invalid_int.m:017: `0b100000000000000000000000000000000'. invalid_int.m:018: Error: integer literal is too big -invalid_int.m:018: `0b100000000000000000000000000000000'. +invalid_int.m:018: `0b1111111111111111111111111111111111111111111111111111111111111111'. invalid_int.m:019: Error: integer literal is too big -invalid_int.m:019: `0b1111111111111111111111111111111111111111111111111111111111111111'. -invalid_int.m:020: Error: integer literal is too big -invalid_int.m:020: `0b10000000000000000000000000000000000000000000000000000000000000000'. -invalid_int.m:023: Error: integer literal is too big `0o40000000000'. +invalid_int.m:019: `0b10000000000000000000000000000000000000000000000000000000000000000'. +invalid_int.m:022: Error: integer literal is too big `0o40000000000'. +invalid_int.m:023: Error: integer literal is too big +invalid_int.m:023: `0o1777777777777777777777'. invalid_int.m:024: Error: integer literal is too big -invalid_int.m:024: `0o1777777777777777777777'. -invalid_int.m:025: Error: integer literal is too big -invalid_int.m:025: `0o2000000000000000000000'. -invalid_int.m:028: Error: integer literal is too big `0x100000000'. -invalid_int.m:029: Error: integer literal is too big `0x110000000'. -invalid_int.m:030: Error: integer literal is too big `0xFFFFFFFFFFFFFFFF'. -invalid_int.m:031: Error: integer literal is too big `0x10000000000000000'. -invalid_int.m:034: Error: integer literal is too big `2147483648'. -invalid_int.m:035: Error: integer literal is too big `9223372036854775807'. -invalid_int.m:036: Error: integer literal is too big `9223372036854775808'. +invalid_int.m:024: `0o2000000000000000000000'. +invalid_int.m:027: Error: integer literal is too big `0x100000000'. +invalid_int.m:028: Error: integer literal is too big `0x110000000'. +invalid_int.m:029: Error: integer literal is too big `0xFFFFFFFFFFFFFFFF'. +invalid_int.m:030: Error: integer literal is too big `0x10000000000000000'. +invalid_int.m:033: Error: integer literal is too big `2147483648'. +invalid_int.m:034: Error: integer literal is too big `9223372036854775807'. +invalid_int.m:035: Error: integer literal is too big `9223372036854775808'. diff --git a/tests/invalid/invalid_int.err_exp2 b/tests/invalid/invalid_int.err_exp2 index 52c84e102..2ff39f543 100644 --- a/tests/invalid/invalid_int.err_exp2 +++ b/tests/invalid/invalid_int.err_exp2 @@ -1,6 +1,6 @@ -invalid_int.m:020: Error: integer literal is too big -invalid_int.m:020: `0b10000000000000000000000000000000000000000000000000000000000000000'. -invalid_int.m:025: Error: integer literal is too big -invalid_int.m:025: `0o2000000000000000000000'. -invalid_int.m:031: Error: integer literal is too big `0x10000000000000000'. -invalid_int.m:036: Error: integer literal is too big `9223372036854775808'. +invalid_int.m:019: Error: integer literal is too big +invalid_int.m:019: `0b10000000000000000000000000000000000000000000000000000000000000000'. +invalid_int.m:024: Error: integer literal is too big +invalid_int.m:024: `0o2000000000000000000000'. +invalid_int.m:030: Error: integer literal is too big `0x10000000000000000'. +invalid_int.m:035: Error: integer literal is too big `9223372036854775808'. diff --git a/tests/invalid/invalid_int.m b/tests/invalid/invalid_int.m index 4fdaeb8f6..8a99191cf 100644 --- a/tests/invalid/invalid_int.m +++ b/tests/invalid/invalid_int.m @@ -10,7 +10,6 @@ :- pred main(io::di, io::uo) is det. :- implementation. -:- import_module list. main(!IO) :- X = { diff --git a/tests/invalid/not_a_switch.err_exp b/tests/invalid/not_a_switch.err_exp index 059cf7cc3..df9105282 100644 --- a/tests/invalid/not_a_switch.err_exp +++ b/tests/invalid/not_a_switch.err_exp @@ -1,6 +1,6 @@ -not_a_switch.m:015: In `not_a_switch'(in, out): -not_a_switch.m:015: error: determinism declaration not satisfied. -not_a_switch.m:015: Declared `det', inferred `nondet'. +not_a_switch.m:014: In `not_a_switch'(in, out): +not_a_switch.m:014: error: determinism declaration not satisfied. +not_a_switch.m:014: Declared `det', inferred `nondet'. not_a_switch.m:019: Disjunction has multiple clauses with solutions. not_a_switch.m:021: Unification of `A' and `maybe.yes(Int2)' can fail. not_a_switch.m:022: In argument 1 of clause head: diff --git a/tests/invalid/not_a_switch.m b/tests/invalid/not_a_switch.m index d84f8a36b..ed3dba09d 100644 --- a/tests/invalid/not_a_switch.m +++ b/tests/invalid/not_a_switch.m @@ -9,12 +9,12 @@ :- interface. -:- import_module int. :- import_module maybe. :- pred not_a_switch(maybe(int)::in, int::out) is det. :- implementation. +:- import_module int. not_a_switch(A, Int1 + Int2) :- Int1 = 1 + 1, diff --git a/tests/invalid/promise_equivalent_solutions_test.err_exp b/tests/invalid/promise_equivalent_solutions_test.err_exp index cd065a9b9..5177d3a5e 100644 --- a/tests/invalid/promise_equivalent_solutions_test.err_exp +++ b/tests/invalid/promise_equivalent_solutions_test.err_exp @@ -1,7 +1,7 @@ -promise_equivalent_solutions_test.m:024: Error: the -promise_equivalent_solutions_test.m:024: `promise_equivalent_solutions' goal -promise_equivalent_solutions_test.m:024: binds a variable that is not listed: -promise_equivalent_solutions_test.m:024: A. -promise_equivalent_solutions_test.m:039: Error: the -promise_equivalent_solutions_test.m:039: `promise_equivalent_solutions' goal -promise_equivalent_solutions_test.m:039: lists an extra variable: ASorted. +promise_equivalent_solutions_test.m:023: Error: the +promise_equivalent_solutions_test.m:023: `promise_equivalent_solutions' goal +promise_equivalent_solutions_test.m:023: binds a variable that is not listed: +promise_equivalent_solutions_test.m:023: A. +promise_equivalent_solutions_test.m:038: Error: the +promise_equivalent_solutions_test.m:038: `promise_equivalent_solutions' goal +promise_equivalent_solutions_test.m:038: lists an extra variable: ASorted. diff --git a/tests/invalid/promise_equivalent_solutions_test.m b/tests/invalid/promise_equivalent_solutions_test.m index 1b2320bcf..8f003a25d 100644 --- a/tests/invalid/promise_equivalent_solutions_test.m +++ b/tests/invalid/promise_equivalent_solutions_test.m @@ -12,7 +12,6 @@ :- pred main(io::di, io::uo) is det. :- implementation. -:- import_module int. :- import_module list. :- import_module string. @@ -29,12 +28,12 @@ main(!IO) :- ; B = [33, 44] ) ), - list__sort_and_remove_dups(A, ASorted), - list__sort_and_remove_dups(B, BSorted), - io__write(ASorted, !IO), - io__nl(!IO), - io__write(BSorted, !IO), - io__nl(!IO), + list.sort_and_remove_dups(A, ASorted), + list.sort_and_remove_dups(B, BSorted), + io.write(ASorted, !IO), + io.nl(!IO), + io.write(BSorted, !IO), + io.nl(!IO), ( promise_equivalent_solutions [C, ASorted] ( ASorted = [_ | ATail], @@ -43,9 +42,9 @@ main(!IO) :- ) ) -> - list__sort_and_remove_dups(C, CSorted), - io__write(CSorted, !IO), - io__nl(!IO) + list.sort_and_remove_dups(C, CSorted), + io.write(CSorted, !IO), + io.nl(!IO) ; - io__write("cannot compute CSorted\n", !IO) + io.write("cannot compute CSorted\n", !IO) ). diff --git a/tests/invalid/reserve_tag.err_exp b/tests/invalid/reserve_tag.err_exp index 009b3c02b..c601a286c 100644 --- a/tests/invalid/reserve_tag.err_exp +++ b/tests/invalid/reserve_tag.err_exp @@ -1,19 +1,19 @@ -reserve_tag.m:025: In `:- pragma reserve_tag' declaration for -reserve_tag.m:025: `reserve_tag.undefined_type'/1: -reserve_tag.m:025: error: undefined type `reserve_tag.undefined_type'/1. -reserve_tag.m:027: Error: expected type name/arity for `:- pragma reserve_tag' -reserve_tag.m:027: declaration, not `(list__list / 1)'. -reserve_tag.m:028: In `:- pragma reserve_tag' declaration for -reserve_tag.m:028: `reserve_tag.list'/1: -reserve_tag.m:028: error: undefined type `reserve_tag.list'/1. -reserve_tag.m:029: In `:- pragma reserve_tag' declaration for -reserve_tag.m:029: `reserve_tag.exported_type'/0: -reserve_tag.m:029: error: `:- pragma reserve_tag' declaration must have the -reserve_tag.m:029: same visibility as the type definition. -reserve_tag.m:036: In `:- pragma reserve_tag' declaration for -reserve_tag.m:036: `reserve_tag.invalid_arity'/1: -reserve_tag.m:036: error: undefined type `reserve_tag.invalid_arity'/1. -reserve_tag.m:049: In `:- pragma reserve_tag' declaration for -reserve_tag.m:049: `reserve_tag.foo'/0: -reserve_tag.m:049: warning: multiple `:- pragma reserved_tag' declarations -reserve_tag.m:049: for the same type. +reserve_tag.m:023: In `:- pragma reserve_tag' declaration for +reserve_tag.m:023: `reserve_tag.undefined_type'/1: +reserve_tag.m:023: error: undefined type `reserve_tag.undefined_type'/1. +reserve_tag.m:025: Error: expected type name/arity for `:- pragma reserve_tag' +reserve_tag.m:025: declaration, not `(list__list / 1)'. +reserve_tag.m:026: In `:- pragma reserve_tag' declaration for +reserve_tag.m:026: `reserve_tag.list'/1: +reserve_tag.m:026: error: undefined type `reserve_tag.list'/1. +reserve_tag.m:027: In `:- pragma reserve_tag' declaration for +reserve_tag.m:027: `reserve_tag.exported_type'/0: +reserve_tag.m:027: error: `:- pragma reserve_tag' declaration must have the +reserve_tag.m:027: same visibility as the type definition. +reserve_tag.m:034: In `:- pragma reserve_tag' declaration for +reserve_tag.m:034: `reserve_tag.invalid_arity'/1: +reserve_tag.m:034: error: undefined type `reserve_tag.invalid_arity'/1. +reserve_tag.m:047: In `:- pragma reserve_tag' declaration for +reserve_tag.m:047: `reserve_tag.foo'/0: +reserve_tag.m:047: warning: multiple `:- pragma reserved_tag' declarations +reserve_tag.m:047: for the same type. diff --git a/tests/invalid/reserve_tag.m b/tests/invalid/reserve_tag.m index 8c33951a6..ac6bc8fc5 100644 --- a/tests/invalid/reserve_tag.m +++ b/tests/invalid/reserve_tag.m @@ -7,7 +7,6 @@ :- module reserve_tag. :- interface. -:- import_module int. :- type exported_type ---> foo(int). :- type abstract_type. @@ -18,7 +17,6 @@ :- func mkfoo(int) = exported_type2. :- implementation. -:- import_module list. mkfoo(X) = foo(X). diff --git a/tests/invalid/specified.err_exp b/tests/invalid/specified.err_exp index a5ed111fa..8783bde9f 100644 --- a/tests/invalid/specified.err_exp +++ b/tests/invalid/specified.err_exp @@ -1,17 +1,17 @@ -specified.m:142: Error in `:- pragma memo' declaration for predicate -specified.m:142: `specified.ap_lp_fib'/3: -specified.m:142: argument 3: argument tabling method `addr' is not compatible -specified.m:142: with output modes. -specified.m:159: Error: expected argument tabling method, not `implied'. -specified.m:174: Error in `:- pragma memo' declaration for predicate -specified.m:174: `specified.ap_li_fib'/3: -specified.m:174: not enough argument tabling methods specified. -specified.m:214: Error in `:- pragma memo' declaration for predicate -specified.m:214: `specified.vp_ll_fib'/3: -specified.m:214: argument 1: argument tabling method `output' is not -specified.m:214: compatible with input modes. -specified.m:234: Error in `:- pragma memo' declaration for predicate -specified.m:234: `specified.vv_ll_fib'/3: -specified.m:234: too many argument tabling methods specified. -specified.m:278: Error: expected one or two arguments for `specified'. -specified.m:286: Error: expected hidden argument tabling method, not `voodoo'. +specified.m:141: Error in `:- pragma memo' declaration for predicate +specified.m:141: `specified.ap_lp_fib'/3: +specified.m:141: argument 3: argument tabling method `addr' is not compatible +specified.m:141: with output modes. +specified.m:158: Error: expected argument tabling method, not `implied'. +specified.m:173: Error in `:- pragma memo' declaration for predicate +specified.m:173: `specified.ap_li_fib'/3: +specified.m:173: not enough argument tabling methods specified. +specified.m:213: Error in `:- pragma memo' declaration for predicate +specified.m:213: `specified.vp_ll_fib'/3: +specified.m:213: argument 1: argument tabling method `output' is not +specified.m:213: compatible with input modes. +specified.m:233: Error in `:- pragma memo' declaration for predicate +specified.m:233: `specified.vv_ll_fib'/3: +specified.m:233: too many argument tabling methods specified. +specified.m:277: Error: expected one or two arguments for `specified'. +specified.m:285: Error: expected hidden argument tabling method, not `voodoo'. diff --git a/tests/invalid/specified.m b/tests/invalid/specified.m index 62ba5e9c3..eeffe8a69 100644 --- a/tests/invalid/specified.m +++ b/tests/invalid/specified.m @@ -12,7 +12,6 @@ :- implementation. -:- import_module assoc_list. :- import_module benchmarking. :- import_module int. :- import_module list. diff --git a/tests/invalid/state_vars_test1.m b/tests/invalid/state_vars_test1.m index cf23e594d..947f171d8 100644 --- a/tests/invalid/state_vars_test1.m +++ b/tests/invalid/state_vars_test1.m @@ -6,12 +6,12 @@ :- interface. -:- import_module int. - :- pred p(int::in, int::out) is det. :- implementation. +:- import_module int. + % Illegally refers to !:X in an if-then-else expr. % p(!X) :- diff --git a/tests/invalid/state_vars_test2.m b/tests/invalid/state_vars_test2.m index f72319b3b..244524a87 100644 --- a/tests/invalid/state_vars_test2.m +++ b/tests/invalid/state_vars_test2.m @@ -6,12 +6,12 @@ :- interface. -:- import_module int. - :- pred p(int::in, int::out) is det. :- implementation. +:- import_module int. + % Illegally refers to !:Y, which has not been explicitly introduced. % p(!X) :- diff --git a/tests/invalid/state_vars_test4.err_exp b/tests/invalid/state_vars_test4.err_exp index 564eebbc4..33d7e07f1 100644 --- a/tests/invalid/state_vars_test4.err_exp +++ b/tests/invalid/state_vars_test4.err_exp @@ -1,10 +1,10 @@ -state_vars_test4.m:012: In function `f'/1: -state_vars_test4.m:012: warning: unresolved polymorphism. -state_vars_test4.m:012: The variables with unbound types were: -state_vars_test4.m:012: STATE_VARIABLE_X: V_1 -state_vars_test4.m:012: STATE_VARIABLE_X_0: V_1 -state_vars_test4.m:012: The unbound type variables will be implicitly bound -state_vars_test4.m:012: to the builtin type `void'. +state_vars_test4.m:011: In function `f'/1: +state_vars_test4.m:011: warning: unresolved polymorphism. +state_vars_test4.m:011: The variables with unbound types were: +state_vars_test4.m:011: STATE_VARIABLE_X: V_1 +state_vars_test4.m:011: STATE_VARIABLE_X_0: V_1 +state_vars_test4.m:011: The unbound type variables will be implicitly bound +state_vars_test4.m:011: to the builtin type `void'. state_vars_test4.m:018: Error: !X cannot be a lambda argument. state_vars_test4.m:018: Perhaps you meant !.X or !:X. state_vars_test4.m:018: In clause for `f(in) = out': diff --git a/tests/invalid/state_vars_test4.m b/tests/invalid/state_vars_test4.m index accb71773..57aeaed3e 100644 --- a/tests/invalid/state_vars_test4.m +++ b/tests/invalid/state_vars_test4.m @@ -6,12 +6,12 @@ :- interface. -:- import_module int. :- import_module list. :- func f(list(int)) = int. :- implementation. +:- import_module int. % Illegally uses !X as a lambda arg. % diff --git a/tests/invalid/state_vars_test5.err_exp b/tests/invalid/state_vars_test5.err_exp index 4c3921740..06c47e55d 100644 --- a/tests/invalid/state_vars_test5.err_exp +++ b/tests/invalid/state_vars_test5.err_exp @@ -1,9 +1,9 @@ -state_vars_test5.m:022: In clause for `p(out)': -state_vars_test5.m:022: mode error: argument 1 did not get sufficiently -state_vars_test5.m:022: instantiated. -state_vars_test5.m:022: Final instantiatedness of `STATE_VARIABLE_X' was -state_vars_test5.m:022: `free', -state_vars_test5.m:022: expected final instantiatedness was `ground'. -state_vars_test5.m:022: In clause for predicate `state_vars_test5.p'/1: -state_vars_test5.m:022: warning: variable `STATE_VARIABLE_X' occurs only once -state_vars_test5.m:022: in this scope. +state_vars_test5.m:020: In clause for `p(out)': +state_vars_test5.m:020: mode error: argument 1 did not get sufficiently +state_vars_test5.m:020: instantiated. +state_vars_test5.m:020: Final instantiatedness of `STATE_VARIABLE_X' was +state_vars_test5.m:020: `free', +state_vars_test5.m:020: expected final instantiatedness was `ground'. +state_vars_test5.m:020: In clause for predicate `state_vars_test5.p'/1: +state_vars_test5.m:020: warning: variable `STATE_VARIABLE_X' occurs only once +state_vars_test5.m:020: in this scope. diff --git a/tests/invalid/state_vars_test5.m b/tests/invalid/state_vars_test5.m index e3f0c5b49..87fb2d1c2 100644 --- a/tests/invalid/state_vars_test5.m +++ b/tests/invalid/state_vars_test5.m @@ -13,8 +13,6 @@ :- interface. -:- import_module int. - :- pred p(int::out) is det. :- implementation. diff --git a/tests/invalid/string_format_bad.err_exp b/tests/invalid/string_format_bad.err_exp index 540c9bf08..f060bcaaa 100644 --- a/tests/invalid/string_format_bad.err_exp +++ b/tests/invalid/string_format_bad.err_exp @@ -1,33 +1,33 @@ +string_format_bad.m:020: Mismatched format and values in call to +string_format_bad.m:020: `string.format'/3: +string_format_bad.m:020: There is no first conversion specifier, but there is +string_format_bad.m:020: an input. string_format_bad.m:022: Mismatched format and values in call to string_format_bad.m:022: `string.format'/3: -string_format_bad.m:022: There is no first conversion specifier, but there is -string_format_bad.m:022: an input. -string_format_bad.m:024: Mismatched format and values in call to -string_format_bad.m:024: `string.format'/3: -string_format_bad.m:024: The first conversion specifier uses the specifier -string_format_bad.m:024: character `d', but the corresponding input is a -string_format_bad.m:024: string. -string_format_bad.m:027: Mismatched format and values in call to `io.format'/4: +string_format_bad.m:022: The first conversion specifier uses the specifier +string_format_bad.m:022: character `d', but the corresponding input is a +string_format_bad.m:022: string. +string_format_bad.m:025: Mismatched format and values in call to `io.format'/4: +string_format_bad.m:025: The first conversion specifier uses the specifier +string_format_bad.m:025: character `d', but the corresponding input is a +string_format_bad.m:025: string. +string_format_bad.m:026: Mismatched format and values in call to `io.format'/5: +string_format_bad.m:026: The first conversion specifier uses the specifier +string_format_bad.m:026: character `d', but the corresponding input is a +string_format_bad.m:026: string. +string_format_bad.m:027: Mismatched format and values in call to +string_format_bad.m:027: `stream.string_writer.format'/5: string_format_bad.m:027: The first conversion specifier uses the specifier string_format_bad.m:027: character `d', but the corresponding input is a string_format_bad.m:027: string. -string_format_bad.m:028: Mismatched format and values in call to `io.format'/5: -string_format_bad.m:028: The first conversion specifier uses the specifier -string_format_bad.m:028: character `d', but the corresponding input is a -string_format_bad.m:028: string. -string_format_bad.m:029: Mismatched format and values in call to -string_format_bad.m:029: `stream.string_writer.format'/5: -string_format_bad.m:029: The first conversion specifier uses the specifier -string_format_bad.m:029: character `d', but the corresponding input is a -string_format_bad.m:029: string. -string_format_bad.m:030: Mismatched format and values in call to `io.format'/4: -string_format_bad.m:030: The first conversion specifier uses the unknown -string_format_bad.m:030: specifier character `w'. -string_format_bad.m:039: Mismatched format and values in call to `io.format'/5: -string_format_bad.m:039: The second conversion specifier uses the specifier -string_format_bad.m:039: character `f', but the corresponding input is an -string_format_bad.m:039: integer. -string_format_bad.m:044: Mismatched format and values in call to `io.format'/5: -string_format_bad.m:044: The first conversion specifier uses the specifier -string_format_bad.m:044: character `d', but the corresponding input is a -string_format_bad.m:044: float. +string_format_bad.m:028: Mismatched format and values in call to `io.format'/4: +string_format_bad.m:028: The first conversion specifier uses the unknown +string_format_bad.m:028: specifier character `w'. +string_format_bad.m:037: Mismatched format and values in call to `io.format'/5: +string_format_bad.m:037: The second conversion specifier uses the specifier +string_format_bad.m:037: character `f', but the corresponding input is an +string_format_bad.m:037: integer. +string_format_bad.m:042: Mismatched format and values in call to `io.format'/5: +string_format_bad.m:042: The first conversion specifier uses the specifier +string_format_bad.m:042: character `d', but the corresponding input is a +string_format_bad.m:042: float. diff --git a/tests/invalid/string_format_bad.m b/tests/invalid/string_format_bad.m index d3f044a35..6d587e741 100644 --- a/tests/invalid/string_format_bad.m +++ b/tests/invalid/string_format_bad.m @@ -11,8 +11,6 @@ :- implementation. :- import_module bool. -:- import_module float. -:- import_module int. :- import_module list. :- import_module stream. :- import_module stream.string_writer. diff --git a/tests/invalid/string_format_unknown.err_exp b/tests/invalid/string_format_unknown.err_exp index e6d1975a4..85798b357 100644 --- a/tests/invalid/string_format_unknown.err_exp +++ b/tests/invalid/string_format_unknown.err_exp @@ -1,29 +1,29 @@ -string_format_unknown.m:023: Unknown format string in call to -string_format_unknown.m:023: `string.format'/3. -string_format_unknown.m:025: Mismatched format and values in call to -string_format_unknown.m:025: `string.format'/3: -string_format_unknown.m:025: The first conversion specifier uses the -string_format_unknown.m:025: specifier character `d', but the corresponding -string_format_unknown.m:025: input is a string. +string_format_unknown.m:021: Unknown format string in call to +string_format_unknown.m:021: `string.format'/3. +string_format_unknown.m:023: Mismatched format and values in call to +string_format_unknown.m:023: `string.format'/3: +string_format_unknown.m:023: The first conversion specifier uses the +string_format_unknown.m:023: specifier character `d', but the corresponding +string_format_unknown.m:023: input is a string. +string_format_unknown.m:026: Mismatched format and values in call to +string_format_unknown.m:026: `io.format'/4: +string_format_unknown.m:026: The first conversion specifier uses the +string_format_unknown.m:026: specifier character `d', but the corresponding +string_format_unknown.m:026: input is a string. +string_format_unknown.m:027: Mismatched format and values in call to +string_format_unknown.m:027: `io.format'/5: +string_format_unknown.m:027: The first conversion specifier uses the +string_format_unknown.m:027: specifier character `d', but the corresponding +string_format_unknown.m:027: input is a string. string_format_unknown.m:028: Mismatched format and values in call to string_format_unknown.m:028: `io.format'/4: -string_format_unknown.m:028: The first conversion specifier uses the -string_format_unknown.m:028: specifier character `d', but the corresponding -string_format_unknown.m:028: input is a string. -string_format_unknown.m:029: Mismatched format and values in call to -string_format_unknown.m:029: `io.format'/5: -string_format_unknown.m:029: The first conversion specifier uses the -string_format_unknown.m:029: specifier character `d', but the corresponding -string_format_unknown.m:029: input is a string. -string_format_unknown.m:030: Mismatched format and values in call to -string_format_unknown.m:030: `io.format'/4: -string_format_unknown.m:030: The first conversion specifier uses the unknown -string_format_unknown.m:030: specifier character `w'. -string_format_unknown.m:040: Unknown format values in call to `io.format'/5. -string_format_unknown.m:041: Unknown format values in call to -string_format_unknown.m:041: `stream.string_writer.format'/5. -string_format_unknown.m:046: Mismatched format and values in call to -string_format_unknown.m:046: `io.format'/5: -string_format_unknown.m:046: The first conversion specifier uses the -string_format_unknown.m:046: specifier character `d', but the corresponding -string_format_unknown.m:046: input is a float. +string_format_unknown.m:028: The first conversion specifier uses the unknown +string_format_unknown.m:028: specifier character `w'. +string_format_unknown.m:038: Unknown format values in call to `io.format'/5. +string_format_unknown.m:039: Unknown format values in call to +string_format_unknown.m:039: `stream.string_writer.format'/5. +string_format_unknown.m:044: Mismatched format and values in call to +string_format_unknown.m:044: `io.format'/5: +string_format_unknown.m:044: The first conversion specifier uses the +string_format_unknown.m:044: specifier character `d', but the corresponding +string_format_unknown.m:044: input is a float. diff --git a/tests/invalid/string_format_unknown.m b/tests/invalid/string_format_unknown.m index 72b428180..d270461fe 100644 --- a/tests/invalid/string_format_unknown.m +++ b/tests/invalid/string_format_unknown.m @@ -11,8 +11,6 @@ :- implementation. :- import_module bool. -:- import_module float. -:- import_module int. :- import_module list. :- import_module stream. :- import_module stream.string_writer. diff --git a/tests/invalid/try_io_else.err_exp b/tests/invalid/try_io_else.err_exp index f9c5e7645..dd201006e 100644 --- a/tests/invalid/try_io_else.err_exp +++ b/tests/invalid/try_io_else.err_exp @@ -1,2 +1,2 @@ -try_io_else.m:022: Error: a `try' goal with an `io' parameter cannot have an -try_io_else.m:022: `else' part. +try_io_else.m:020: Error: a `try' goal with an `io' parameter cannot have an +try_io_else.m:020: `else' part. diff --git a/tests/invalid/try_io_else.m b/tests/invalid/try_io_else.m index 5a888405e..046f68a35 100644 --- a/tests/invalid/try_io_else.m +++ b/tests/invalid/try_io_else.m @@ -14,8 +14,6 @@ :- implementation. -:- import_module exception. - %---------------------------------------------------------------------------% main(!IO) :- diff --git a/tests/invalid/uniq_modes.err_exp b/tests/invalid/uniq_modes.err_exp index 691d29aaf..a5b7540ce 100644 --- a/tests/invalid/uniq_modes.err_exp +++ b/tests/invalid/uniq_modes.err_exp @@ -1,5 +1,5 @@ -uniq_modes.m:017: In clause for `main(di, uo)': -uniq_modes.m:017: in argument 2 of call to predicate `io.write'/3: -uniq_modes.m:017: mode error: variable `In' has instantiatedness -uniq_modes.m:017: `mostly_unique', -uniq_modes.m:017: expected instantiatedness was `unique'. +uniq_modes.m:015: In clause for `main(di, uo)': +uniq_modes.m:015: in argument 2 of call to predicate `io.write'/3: +uniq_modes.m:015: mode error: variable `In' has instantiatedness +uniq_modes.m:015: `mostly_unique', +uniq_modes.m:015: expected instantiatedness was `unique'. diff --git a/tests/invalid/uniq_modes.m b/tests/invalid/uniq_modes.m index 8bff1990b..f4405a287 100644 --- a/tests/invalid/uniq_modes.m +++ b/tests/invalid/uniq_modes.m @@ -10,8 +10,6 @@ :- mode main(di, uo) is det. :- implementation. -:- import_module list. -:- import_module std_util. main(In, _Out) :- io__write("looking for", In, Int1), diff --git a/tests/invalid/zinc2mer_lib.err_exp b/tests/invalid/zinc2mer_lib.err_exp index dc464f439..8b685da88 100644 --- a/tests/invalid/zinc2mer_lib.err_exp +++ b/tests/invalid/zinc2mer_lib.err_exp @@ -1,12 +1,12 @@ -zinc2mer_lib.m:039: In clause for `min_domsize_min_split(ia, oa)': -zinc2mer_lib.m:039: in the return value of call to function -zinc2mer_lib.m:039: `zinc2mer_lib.min_split_var'/1: -zinc2mer_lib.m:039: mode error: variable `BranchConstraints' has -zinc2mer_lib.m:039: instantiatedness `free', -zinc2mer_lib.m:039: expected instantiatedness was `any'. -zinc2mer_lib.m:041: In `min_split_var'(in(any)) = in(any): -zinc2mer_lib.m:041: error: determinism declaration not satisfied. -zinc2mer_lib.m:041: Declared `det', inferred `semidet'. -zinc2mer_lib.m:049: Unification of `BranchConstraints' and `list.[]' can -zinc2mer_lib.m:049: fail. +zinc2mer_lib.m:038: In clause for `min_domsize_min_split(ia, oa)': +zinc2mer_lib.m:038: in the return value of call to function +zinc2mer_lib.m:038: `zinc2mer_lib.min_split_var'/1: +zinc2mer_lib.m:038: mode error: variable `BranchConstraints' has +zinc2mer_lib.m:038: instantiatedness `free', +zinc2mer_lib.m:038: expected instantiatedness was `any'. +zinc2mer_lib.m:040: In `min_split_var'(in(any)) = in(any): +zinc2mer_lib.m:040: error: determinism declaration not satisfied. +zinc2mer_lib.m:040: Declared `det', inferred `semidet'. +zinc2mer_lib.m:048: Unification of `BranchConstraints' and `list.[]' can +zinc2mer_lib.m:048: fail. For more information, recompile with `-E'. diff --git a/tests/invalid/zinc2mer_lib.m b/tests/invalid/zinc2mer_lib.m index 1a213b275..35e2fbb73 100644 --- a/tests/invalid/zinc2mer_lib.m +++ b/tests/invalid/zinc2mer_lib.m @@ -31,7 +31,6 @@ :- implementation. -:- import_module int. :- import_module require. min_domsize_min_split([], _) :- error("empty list"). diff --git a/tests/invalid_purity/impure_func_t2.err_exp b/tests/invalid_purity/impure_func_t2.err_exp index 16c367c45..f11b9856d 100644 --- a/tests/invalid_purity/impure_func_t2.err_exp +++ b/tests/invalid_purity/impure_func_t2.err_exp @@ -1,4 +1,4 @@ -impure_func_t2.m:021: In call to impure function -impure_func_t2.m:021: `impure_func_t2.get_counter'/0: -impure_func_t2.m:021: purity error: call must be in an explicit unification -impure_func_t2.m:021: which is preceded by `impure' indicator. +impure_func_t2.m:018: In call to impure function +impure_func_t2.m:018: `impure_func_t2.get_counter'/0: +impure_func_t2.m:018: purity error: call must be in an explicit unification +impure_func_t2.m:018: which is preceded by `impure' indicator. diff --git a/tests/invalid_purity/impure_func_t2.m b/tests/invalid_purity/impure_func_t2.m index 29edc4e62..8df7d0ef1 100644 --- a/tests/invalid_purity/impure_func_t2.m +++ b/tests/invalid_purity/impure_func_t2.m @@ -12,9 +12,6 @@ :- implementation. -:- import_module int. -:- import_module require. - :- pragma promise_pure(main/2). main --> diff --git a/tests/invalid_purity/impure_func_t3.err_exp b/tests/invalid_purity/impure_func_t3.err_exp index 29db1543c..b6052c17a 100644 --- a/tests/invalid_purity/impure_func_t3.err_exp +++ b/tests/invalid_purity/impure_func_t3.err_exp @@ -1,7 +1,7 @@ -impure_func_t3.m:022: In call to impure function -impure_func_t3.m:022: `impure_func_t3.get_counter'/0: -impure_func_t3.m:022: purity error: call must be in an explicit unification -impure_func_t3.m:022: which is preceded by `impure' indicator. -impure_func_t3.m:022: In call to predicate `io.print'/3: -impure_func_t3.m:022: warning: unnecessary `impure' indicator. -impure_func_t3.m:022: No purity indicator is necessary. +impure_func_t3.m:019: In call to impure function +impure_func_t3.m:019: `impure_func_t3.get_counter'/0: +impure_func_t3.m:019: purity error: call must be in an explicit unification +impure_func_t3.m:019: which is preceded by `impure' indicator. +impure_func_t3.m:019: In call to predicate `io.print'/3: +impure_func_t3.m:019: warning: unnecessary `impure' indicator. +impure_func_t3.m:019: No purity indicator is necessary. diff --git a/tests/invalid_purity/impure_func_t3.m b/tests/invalid_purity/impure_func_t3.m index 9a92a93cd..cc5ff669e 100644 --- a/tests/invalid_purity/impure_func_t3.m +++ b/tests/invalid_purity/impure_func_t3.m @@ -12,9 +12,6 @@ :- implementation. -:- import_module int. -:- import_module require. - :- pragma promise_pure(main/2). main --> diff --git a/tests/invalid_purity/impure_func_t4.err_exp b/tests/invalid_purity/impure_func_t4.err_exp index 198369da6..affd9e8b2 100644 --- a/tests/invalid_purity/impure_func_t4.err_exp +++ b/tests/invalid_purity/impure_func_t4.err_exp @@ -1,4 +1,4 @@ -impure_func_t4.m:022: In call to semipure function -impure_func_t4.m:022: `impure_func_t4.get_counter'/0: -impure_func_t4.m:022: purity error: call must be in an explicit unification -impure_func_t4.m:022: which is preceded by `semipure' indicator. +impure_func_t4.m:019: In call to semipure function +impure_func_t4.m:019: `impure_func_t4.get_counter'/0: +impure_func_t4.m:019: purity error: call must be in an explicit unification +impure_func_t4.m:019: which is preceded by `semipure' indicator. diff --git a/tests/invalid_purity/impure_func_t4.m b/tests/invalid_purity/impure_func_t4.m index 68afbb42e..06b0da26a 100644 --- a/tests/invalid_purity/impure_func_t4.m +++ b/tests/invalid_purity/impure_func_t4.m @@ -12,9 +12,6 @@ :- implementation. -:- import_module int. -:- import_module require. - :- pragma promise_pure(main/2). main --> diff --git a/tests/invalid_purity/impure_func_t5_fixed.err_exp b/tests/invalid_purity/impure_func_t5_fixed.err_exp index 0524712f6..b3ab9abf3 100644 --- a/tests/invalid_purity/impure_func_t5_fixed.err_exp +++ b/tests/invalid_purity/impure_func_t5_fixed.err_exp @@ -1,8 +1,8 @@ -impure_func_t5_fixed.m:030: In clause for `main(di, uo)': -impure_func_t5_fixed.m:030: in argument 2 (i.e. argument 1 of the called -impure_func_t5_fixed.m:030: function) of impure higher-order function call: -impure_func_t5_fixed.m:030: mode error: variable `V_12' has instantiatedness -impure_func_t5_fixed.m:030: `free', -impure_func_t5_fixed.m:030: expected instantiatedness was `ground'. -impure_func_t5_fixed.m:030: The goal could not be reordered, because it was -impure_func_t5_fixed.m:030: impure. +impure_func_t5_fixed.m:026: In clause for `main(di, uo)': +impure_func_t5_fixed.m:026: in argument 2 (i.e. argument 1 of the called +impure_func_t5_fixed.m:026: function) of impure higher-order function call: +impure_func_t5_fixed.m:026: mode error: variable `V_12' has instantiatedness +impure_func_t5_fixed.m:026: `free', +impure_func_t5_fixed.m:026: expected instantiatedness was `ground'. +impure_func_t5_fixed.m:026: The goal could not be reordered, because it was +impure_func_t5_fixed.m:026: impure. diff --git a/tests/invalid_purity/impure_func_t5_fixed.m b/tests/invalid_purity/impure_func_t5_fixed.m index bd4b826be..9c0930d35 100644 --- a/tests/invalid_purity/impure_func_t5_fixed.m +++ b/tests/invalid_purity/impure_func_t5_fixed.m @@ -14,10 +14,6 @@ :- implementation. -:- import_module int. -:- import_module list. -:- import_module require. - :- type foo ---> foo(impure func(int) = int). diff --git a/tests/invalid_purity/impure_func_t7.err_exp b/tests/invalid_purity/impure_func_t7.err_exp index f1cf40340..6b5881560 100644 --- a/tests/invalid_purity/impure_func_t7.err_exp +++ b/tests/invalid_purity/impure_func_t7.err_exp @@ -1,8 +1,8 @@ -impure_func_t7.m:035: Purity error: unification with expression was declared -impure_func_t7.m:035: impure, but expression was not a function call. -impure_func_t7.m:043: Purity error: unification with expression was declared -impure_func_t7.m:043: impure, but expression was not a function call. -impure_func_t7.m:052: Purity error: unification with expression was declared -impure_func_t7.m:052: impure, but expression was not a function call. -impure_func_t7.m:060: Purity error: unification with expression was declared -impure_func_t7.m:060: impure, but expression was not a function call. +impure_func_t7.m:032: Purity error: unification with expression was declared +impure_func_t7.m:032: impure, but expression was not a function call. +impure_func_t7.m:040: Purity error: unification with expression was declared +impure_func_t7.m:040: impure, but expression was not a function call. +impure_func_t7.m:049: Purity error: unification with expression was declared +impure_func_t7.m:049: impure, but expression was not a function call. +impure_func_t7.m:057: Purity error: unification with expression was declared +impure_func_t7.m:057: impure, but expression was not a function call. diff --git a/tests/invalid_purity/impure_func_t7.m b/tests/invalid_purity/impure_func_t7.m index efef1488c..dc3d46ee2 100644 --- a/tests/invalid_purity/impure_func_t7.m +++ b/tests/invalid_purity/impure_func_t7.m @@ -12,9 +12,6 @@ :- implementation. -:- import_module int. -:- import_module require. - :- pragma promise_pure(main/2). :- type blah diff --git a/tests/valid/quantifier_warning.m b/tests/valid/quantifier_warning.m index 14d0f5574..40aebb8b8 100644 --- a/tests/valid/quantifier_warning.m +++ b/tests/valid/quantifier_warning.m @@ -14,7 +14,6 @@ :- implementation. :- import_module bool. :- import_module int. -:- import_module std_util. main --> { p(1, R) }, diff --git a/tests/valid/solv.m b/tests/valid/solv.m index 7c85668db..cfd2e83db 100644 --- a/tests/valid/solv.m +++ b/tests/valid/solv.m @@ -13,7 +13,6 @@ :- module solv. :- interface. -:- import_module int. :- import_module io. :- import_module list. diff --git a/tests/valid/spurious_purity_warning.m b/tests/valid/spurious_purity_warning.m index 36fff6d14..b4ca82646 100644 --- a/tests/valid/spurious_purity_warning.m +++ b/tests/valid/spurious_purity_warning.m @@ -10,7 +10,6 @@ :- implementation. :- import_module require. -:- import_module std_util. foo(X::out) :- ( semidet_succeed -> diff --git a/tests/warnings/det_infer_warning.m b/tests/warnings/det_infer_warning.m index e84256bb4..940019d0e 100644 --- a/tests/warnings/det_infer_warning.m +++ b/tests/warnings/det_infer_warning.m @@ -21,8 +21,6 @@ :- implementation. -:- import_module require. - test :- ( cond(true) diff --git a/tests/warnings/foreign_term_invalid.exp b/tests/warnings/foreign_term_invalid.exp index d76a13c87..4fc5b39ad 100644 --- a/tests/warnings/foreign_term_invalid.exp +++ b/tests/warnings/foreign_term_invalid.exp @@ -1,8 +1,8 @@ -foreign_term_invalid.m:013: Warning: predicate `foreign_term_invalid.test1'/1 -foreign_term_invalid.m:013: mode 0 has a `:- pragma does_not_terminate' -foreign_term_invalid.m:013: declaration but also has the `terminates' foreign -foreign_term_invalid.m:013: code attribute set. -foreign_term_invalid.m:014: Warning: predicate `foreign_term_invalid.test2'/1 -foreign_term_invalid.m:014: mode 0 has a `:- pragma terminates' declaration -foreign_term_invalid.m:014: but also has the `does_not_terminate' foreign -foreign_term_invalid.m:014: code attribute set. +foreign_term_invalid.m:011: Warning: predicate `foreign_term_invalid.test1'/1 +foreign_term_invalid.m:011: mode 0 has a `:- pragma does_not_terminate' +foreign_term_invalid.m:011: declaration but also has the `terminates' foreign +foreign_term_invalid.m:011: code attribute set. +foreign_term_invalid.m:012: Warning: predicate `foreign_term_invalid.test2'/1 +foreign_term_invalid.m:012: mode 0 has a `:- pragma terminates' declaration +foreign_term_invalid.m:012: but also has the `does_not_terminate' foreign +foreign_term_invalid.m:012: code attribute set. diff --git a/tests/warnings/foreign_term_invalid.m b/tests/warnings/foreign_term_invalid.m index 70b19310a..205314476 100644 --- a/tests/warnings/foreign_term_invalid.m +++ b/tests/warnings/foreign_term_invalid.m @@ -8,8 +8,6 @@ :- interface. -:- import_module int. - :- pred test1(int::out) is det. :- pred test2(int::out) is det. diff --git a/tests/warnings/infinite_recursion.exp b/tests/warnings/infinite_recursion.exp index 2998ed073..a43a5f53f 100644 --- a/tests/warnings/infinite_recursion.exp +++ b/tests/warnings/infinite_recursion.exp @@ -1,6 +1,6 @@ -infinite_recursion.m:018: Warning: recursive call will lead to infinite -infinite_recursion.m:018: recursion. -infinite_recursion.m:027: Warning: recursive call will lead to infinite -infinite_recursion.m:027: recursion. -infinite_recursion.m:039: Warning: recursive call will lead to infinite -infinite_recursion.m:039: recursion. +infinite_recursion.m:017: Warning: recursive call will lead to infinite +infinite_recursion.m:017: recursion. +infinite_recursion.m:026: Warning: recursive call will lead to infinite +infinite_recursion.m:026: recursion. +infinite_recursion.m:038: Warning: recursive call will lead to infinite +infinite_recursion.m:038: recursion. diff --git a/tests/warnings/infinite_recursion.m b/tests/warnings/infinite_recursion.m index 80bae07db..cf1393229 100644 --- a/tests/warnings/infinite_recursion.m +++ b/tests/warnings/infinite_recursion.m @@ -11,7 +11,6 @@ :- implementation. :- import_module list. -:- import_module std_util. main --> ( { funny_append([1, 2, 3], [4, 5, 6], [5, 6, 7]) } -> diff --git a/tests/warnings/pragma_source_file.m b/tests/warnings/pragma_source_file.m index 08804112e..6ce35d7dd 100644 --- a/tests/warnings/pragma_source_file.m +++ b/tests/warnings/pragma_source_file.m @@ -6,7 +6,6 @@ :- interface. -:- import_module int. :- import_module list. :- pred my_append(list(int), list(int), list(int)). diff --git a/tests/warnings/purity_warnings.exp b/tests/warnings/purity_warnings.exp index 1dabc6bc1..a0e1a3ca4 100644 --- a/tests/warnings/purity_warnings.exp +++ b/tests/warnings/purity_warnings.exp @@ -1,25 +1,25 @@ -purity_warnings.m:029: In call to predicate `io.write_string'/3: -purity_warnings.m:029: warning: unnecessary `semipure' indicator. -purity_warnings.m:029: No purity indicator is necessary. -purity_warnings.m:030: In call to predicate `io.print'/3: -purity_warnings.m:030: warning: unnecessary `impure' indicator. -purity_warnings.m:030: No purity indicator is necessary. -purity_warnings.m:032: In predicate `impure_pred1'/2: -purity_warnings.m:032: warning: declared impure but actually pure. -purity_warnings.m:036: In predicate `impure_pred2'/2: -purity_warnings.m:036: warning: declared impure but actually semipure. -purity_warnings.m:042: In predicate `semipure_pred'/2: -purity_warnings.m:042: warning: declared semipure but actually pure. -purity_warnings.m:044: In call to predicate `io.write_string'/3: -purity_warnings.m:044: warning: unnecessary `semipure' indicator. -purity_warnings.m:044: No purity indicator is necessary. -purity_warnings.m:068: In predicate `impure_method1a_impl'/2: -purity_warnings.m:068: warning: declared impure but actually pure. -purity_warnings.m:070: In predicate `semipure_method_a_impl'/2: -purity_warnings.m:070: warning: declared semipure but actually pure. -purity_warnings.m:073: In call to predicate `io.print'/3: -purity_warnings.m:073: warning: unnecessary `impure' indicator. -purity_warnings.m:073: No purity indicator is necessary. -purity_warnings.m:079: In call to predicate `io.print'/3: -purity_warnings.m:079: warning: unnecessary `semipure' indicator. -purity_warnings.m:079: No purity indicator is necessary. +purity_warnings.m:027: In call to predicate `io.write_string'/3: +purity_warnings.m:027: warning: unnecessary `semipure' indicator. +purity_warnings.m:027: No purity indicator is necessary. +purity_warnings.m:028: In call to predicate `io.print'/3: +purity_warnings.m:028: warning: unnecessary `impure' indicator. +purity_warnings.m:028: No purity indicator is necessary. +purity_warnings.m:030: In predicate `impure_pred1'/2: +purity_warnings.m:030: warning: declared impure but actually pure. +purity_warnings.m:034: In predicate `impure_pred2'/2: +purity_warnings.m:034: warning: declared impure but actually semipure. +purity_warnings.m:040: In predicate `semipure_pred'/2: +purity_warnings.m:040: warning: declared semipure but actually pure. +purity_warnings.m:042: In call to predicate `io.write_string'/3: +purity_warnings.m:042: warning: unnecessary `semipure' indicator. +purity_warnings.m:042: No purity indicator is necessary. +purity_warnings.m:066: In predicate `impure_method1a_impl'/2: +purity_warnings.m:066: warning: declared impure but actually pure. +purity_warnings.m:068: In predicate `semipure_method_a_impl'/2: +purity_warnings.m:068: warning: declared semipure but actually pure. +purity_warnings.m:071: In call to predicate `io.print'/3: +purity_warnings.m:071: warning: unnecessary `impure' indicator. +purity_warnings.m:071: No purity indicator is necessary. +purity_warnings.m:077: In call to predicate `io.print'/3: +purity_warnings.m:077: warning: unnecessary `semipure' indicator. +purity_warnings.m:077: No purity indicator is necessary. diff --git a/tests/warnings/purity_warnings.m b/tests/warnings/purity_warnings.m index 753d785f7..c4b1066f5 100644 --- a/tests/warnings/purity_warnings.m +++ b/tests/warnings/purity_warnings.m @@ -12,8 +12,6 @@ :- implementation. -:- import_module int. -:- import_module list. :- import_module string. main --> diff --git a/tests/warnings/singleton_test.m b/tests/warnings/singleton_test.m index 769b1ccb8..8e77b3f1a 100644 --- a/tests/warnings/singleton_test.m +++ b/tests/warnings/singleton_test.m @@ -25,7 +25,7 @@ is det. :- implementation. -:- import_module int. +% :- import_module int. my_append([], L, L) :- L = L2. diff --git a/tests/warnings/state_vars_test.exp b/tests/warnings/state_vars_test.exp index 44e40bd7c..0e6ce9e15 100644 --- a/tests/warnings/state_vars_test.exp +++ b/tests/warnings/state_vars_test.exp @@ -1 +1 @@ -state_vars_test.m:024: Warning: reference to uninitialized state variable !.X. +state_vars_test.m:022: Warning: reference to uninitialized state variable !.X. diff --git a/tests/warnings/state_vars_test.m b/tests/warnings/state_vars_test.m index 03243a132..e166c7839 100644 --- a/tests/warnings/state_vars_test.m +++ b/tests/warnings/state_vars_test.m @@ -12,8 +12,6 @@ :- implementation. -:- import_module int. - main(!IO). :- pred p(int::out) is det.