Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue a warning when old is used on a non-modified variable #123

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

n-osborne
Copy link
Contributor

@n-osborne n-osborne commented Dec 17, 2021

Fixes #39.

@n-osborne n-osborne requested a review from pascutto April 11, 2022 14:17
Copy link
Contributor

@pascutto pascutto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ! I would argue for splitting the two new warnings, since one seems easier to implement than the other

Comment on lines +643 to +650
| Tvar vs ->
if
not
(List.exists
(function { t_node = Tvar vs' } -> vs = vs' | _ -> false)
wr)
then Some vs.vs_name.id_str
else None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that would be enough. For instance, you would reject the following:

val f : 'a array -> unit
(*@ f x 
    modifies x 
    ensures let y = x in old y.(0) = 0

You need a more subtle data flow analysis to know which variables are actually modified when you write modifies x.

Co-authored-by: Clément Pascutto <[email protected]>
@n-osborne
Copy link
Contributor Author

Thanks ! I would argue for splitting the two new warnings, since one seems easier to implement than the other

You mean in two different PRs?

n-osborne and others added 2 commits April 12, 2022 11:47
Co-authored-by: Clément Pascutto <[email protected]>
Co-authored-by: Clément Pascutto <[email protected]>
Co-authored-by: Clément Pascutto <[email protected]>
@pascutto pascutto marked this pull request as draft April 20, 2022 11:46
@pascutto pascutto changed the title Warnings Issue a warning when old is used on a non-modified variable Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue a warning when old is used on a read-only expression
2 participants