[m-rev.] for review: fix mantis bug 412
Peter Wang
novalazy at gmail.com
Sun Jul 17 12:19:00 AEST 2016
On Sat, 16 Jul 2016 20:53:19 +0200 (CEST), "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> On Sat, 16 Jul 2016 12:07:56 +1000, Peter Wang <novalazy at gmail.com> wrote:
> > The proposed change will cause the compiler to warn about a module
> > being unused if it is imported ONLY for a class definition, even if it
> > is necessarily imported by the current module in order to define an
> > instance of that class.
>
> Thanks. I discovered that problem myself just before I got your email.
>
> > Perhaps a fix is along these lines: only instances defined in "this"
> > module should "use" the modules defining the class and types in the
> > instance. Instances defined in imported modules would be ignored.
>
> I think that works. Here is an updated diff that uses your approach,
> not the one I used originally.
Thanks, Zoltan. It looks fine.
> browser/browse.m:
> compiler/add_mutable_aux_preds.m:
> compiler/add_pred.m:
> compiler/add_special_pred.m:
> compiler/check_for_missing_type_defns.m:
> compiler/check_promise.m:
> compiler/exception_analysis.m:
> compiler/handle_options.m:
> compiler/inst_match.m:
> compiler/mercury_to_mercury.m:
> compiler/ml_tailcall.m:
> compiler/module_qual.m:
> compiler/op_mode.m:
> compiler/parse_inst_mode_defn.m:
> compiler/parse_tree_out_clause.m:
> compiler/parse_tree_out_info.m:
> compiler/parse_tree_out_inst.m:
> compiler/parse_tree_out_pragma.m:
> compiler/parse_tree_out_pred_decl.m:
> compiler/parse_tree_out_term.m:
> compiler/parse_type_defn.m:
> compiler/parse_type_name.m:
> compiler/parse_util.m:
> compiler/parse_vars.m:
> compiler/prog_ctgc.m:
> compiler/recompilation.usage.m:
> compiler/resolve_unify_functor.m:
> compiler/term_constr_main.m:
> compiler/term_constr_main_types.m:
> compiler/write_deps_file.m:
> library/bt_array.m:
>
Delete unused imports.
> diff --git a/compiler/unused_imports.m b/compiler/unused_imports.m
> index 430085d..375d00a 100644
> --- a/compiler/unused_imports.m
> +++ b/compiler/unused_imports.m
...
> - module_info_get_const_struct_db(ModuleInfo, ConstStructDb),
> - const_struct_db_get_structs(ConstStructDb, ConstStructs),
> - list.foldl(const_struct_used_modules, ConstStructs, !UsedModules),
> + % We do not want to generate unused module warnings for implicitly
> + % imported modules, since the user cannot prevent their imports.
> + % We therefore include them as "used" modules.
> + % XXX We can do better in two different ways.
> + % (1) Instead of considering *all** builtin modules to be used,
*all*
Peter
More information about the reviews
mailing list