-
Notifications
You must be signed in to change notification settings - Fork 256
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
No verification error when "reads this" is missing #3911
Comments
That's strange, we are not raising the error that the predicate is reading "this" which is not part of its reads clause. That should be investigated. Anyway, even if this is possible in a postcondition now, it's not possible in a body. An upcoming PR will trigger a verification warning in your case |
That makes sense. Thanks for the explanation. Looking at #3553, it seems like this would give a warning for the current example but wouldn't help if |
More generally, it would be nice to get a warning when I get into a state where a contradiction has been introduced. I'm new to dafny and my current approach is just to write |
There are cases where you want to |
Postconditions of functions are not subject to reads checks. This is why the given postcondition is admitted. However, as @MikaelMayer pointed out, you won't be able to implement the body of Presently, the warning that reminds you that The best way to make sure your postcondition specifications are feasible is to provide an implementation. If for some reason you don't want to do that (for example, if the function or method is an extern, provided by some non-Dafny code), then you can use module refinement to supply a throwaway body (see https://github.com/dafny-lang/dafny/wiki/Modeling-External-State-Correctly). Similarly, the best way to make sure your precondition specifications are feasible is to provide a caller. |
I didn't check just now, but does the reference manual say that postconditions are not subject to reads checks? If so, then we can close this Issue. If not, then we should mark this issue with a Documentation tag. |
One more point on this subject, Dafny has an Auditor capability. It report things that a program accidentally or on purpose hides from the verifier. From the command line, you invoke it like
|
In addition to the auditor, we're also in the design phase for an analysis that should be able to detect many cases of contradictory assumptions. |
Great, thanks for all of this really useful information. I think the main point I was missing is that even for a ghost function I should be writing a body to help catch the bugs in my postconditions. |
I tried to summarize the points made in an answer to my own question on stackoverflow. |
Dafny version
4.0.0.50303
Code to produce this issue
Command to run and resulting output
What happened?
This example should fail verification.
What type of operating system are you experiencing the problem on?
Windows
The text was updated successfully, but these errors were encountered: