[m-rev.] for review: implement --warn-suspicious-recursion
Julien Fischer
jfischer at opturion.com
Wed May 1 15:34:20 AEST 2019
On Wed, 1 May 2019, Zoltan Somogyi wrote:
> For review by anyone, but I would like the person who last worked on
> to_char_list in string.m to review the diff to string.m, even if he does not
> look at the rest of the diff.
A couple more comments in addition to those from Peter:
> Implement warnings for suspicious recursion.
>
> compiler/simplify_goal_call.m:
> If the --warn-suspicious-recursion option is set, and if the warning
> isn't disable, generate warnings for two different kinds of suspicious
s/disable/disabled/
> recursion. They are both related to, but separate from, the warning
> we have long generated for infinite recursion, which occurs when
> the input args of a recursive call are the same as the corresponding
> args in the clause head.
>
> Both kinds suspicious recursion look at the input args of a recursive call
> that are NOT the same as the corresponding args in the clause head.
> Both require these args to have non-unique modes. (If they have unique
> modes, then the depth of the recursion may be controlled by state outside
> the view of the Mercury compiler, which means that a warning would be
> likely to be misleading.)
Unless the unique arguments *only* occur in the recursive calls, in which case
you could issue the warning. That may be a case worth including here since
it's not unheard of for users to thread the I/O (or other unique) state through
a predicate and then not use it.
Julien.
More information about the reviews
mailing list