[m-rev.] for review: warn about unneeded initial and final state vars

Zoltan Somogyi zoltan.somogyi at runbox.com
Thu May 22 12:21:48 AEST 2025



On Wed, 21 May 2025 13:05:40 +1000, Peter Wang <novalazy at gmail.com> wrote:

> On Tue, 20 May 2025 17:13:42 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> > This means that this code cannot base its decisions on the answers
> > to questions such as "what is the mode of this argument"; it has to
> > fall back to questions "what are the *possible* modes of this argument".
> > In this case, I think that still works. We could add a heuristic that says
> > "do not generate an unneeded final statevar warning if either the initial
> > or the final inst of the argument represented by that final statevar,
> > in *any* of the declared modes of the predicate, involve either
> > uniqueness, or its converse, being clobbered".
> > 
> > Would that work to shut up the unwanted warnings for the cases
> > you have seen? And can you think of any other heuristic that would help
> > in other cases of false positives?
> 
> That would work. I can't think of anything else right now.

The attached diff implements the agreed approach, and also uses
different forms of the diagnostic depending on whether only the final
version is unneeded, or both the initial and final versions.

Note that this diff implements both this distinction, and the new heuristic,
only for state vars in clause heads, not in lambda expressions. I will update
the code for lambda expressions after this diff is reviewed and committed.

For review by Peter.

Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.usw4
Type: application/octet-stream
Size: 1739 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20250522/d9cdc1d3/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.usw4
Type: application/octet-stream
Size: 31228 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20250522/d9cdc1d3/attachment-0003.obj>


More information about the reviews mailing list