[m-rev.] for review: --warn-repeated-singleton-vars
Julien Fischer
jfischer at opturion.com
Tue Dec 10 14:32:28 AEDT 2024
On Tue, 10 Dec 2024 at 04:28, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
> Add the --warn-repeated-singleton-vars option ...
>
> ... effectively replacing part of the functionality of the existing
> --warn-singleton-vars option.
...
> diff --git a/compiler/make_hlds_warn.m b/compiler/make_hlds_warn.m
> index 657ba63b4..e00d15ec5 100644
> --- a/compiler/make_hlds_warn.m
> +++ b/compiler/make_hlds_warn.m
...
> @@ -379,36 +441,39 @@ warn_singletons_in_goal(Goal, QuantVars, !Info) :-
> ThenVars = free_goal_vars(Then),
> set_of_var.union(CondVars, ThenVars, CondThenVars),
> set_of_var.init(EmptySet),
> - warn_singletons_goal_vars(Vars, GoalInfo, EmptySet, CondThenVars,
> - !Info)
> + warn_singletons_goal_vars(Params, Vars, GoalInfo, EmptySet,
> + CondThenVars, !Info)
> ;
> Vars = []
> ),
> set_of_var.insert_list(Vars, QuantVars, CondThenQuantVars),
> - warn_singletons_in_goal(Cond, CondThenQuantVars, !Info),
> - warn_singletons_in_goal(Then, CondThenQuantVars, !Info),
> - warn_singletons_in_goal(Else, QuantVars, !Info)
> + warn_singletons_in_goal(Params, Cond, CondThenQuantVars, !Info),
> + warn_singletons_in_goal(Params, Then, CondThenQuantVars, !Info),
> + warn_singletons_in_goal(Params, Else, QuantVars, !Info)
> ;
> GoalExpr = plain_call(_, _, Args, _, _, _),
> NonLocals = goal_info_get_nonlocals(GoalInfo),
> - warn_singletons_goal_vars(Args, GoalInfo, NonLocals, QuantVars, !Info)
> + warn_singletons_goal_vars(Params, Args, GoalInfo, NonLocals,
> + QuantVars, !Info)
> ;
> GoalExpr = generic_call(GenericCall, Args0, _, _, _),
> goal_util.generic_call_vars(GenericCall, Args1),
> Args = Args0 ++ Args1,
> NonLocals = goal_info_get_nonlocals(GoalInfo),
> - warn_singletons_goal_vars(Args, GoalInfo, NonLocals, QuantVars, !Info)
> + warn_singletons_goal_vars(Params, Args, GoalInfo, NonLocals,
> + QuantVars, !Info)
> ;
> GoalExpr = unify(Var, RHS, _, _, _),
> - warn_singletons_in_unify(Var, RHS, GoalInfo, QuantVars, !Info)
> + warn_singletons_in_unify(Params, Var, RHS, GoalInfo, QuantVars, !Info)
> ;
> GoalExpr = call_foreign_proc(Attrs, PredId, ProcId, Args, _, _,
> PragmaImpl),
> Context = goal_info_get_context(GoalInfo),
> Lang = get_foreign_language(Attrs),
> NamesModes = list.map(foreign_arg_maybe_name_mode, Args),
> - warn_singletons_in_pragma_foreign_proc(!.Info ^ wi_module_info,
> - PragmaImpl, Lang, NamesModes, Context, !.Info ^ wi_pf_sna,
> + % ZZZ
> + warn_singletons_in_pragma_foreign_proc(Params ^ wp_module_info,
> + PragmaImpl, Lang, NamesModes, Context, Params ^ wp_pf_sna,
> PredId, ProcId, [], PragmaSpecs),
> add_warn_specs(PragmaSpecs, !Info)
Have you left that ZZZ there for a reason?
The diff looks fine otherwise.
Julien.
More information about the reviews
mailing list