-
Notifications
You must be signed in to change notification settings - Fork 262
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
Missing (!new) check #4926
Comments
…ault expressions Fixes dafny-lang#4926
…ult expressions (#4928) This PR adds checks for correct instantiations of type parameters that were previously missing. Previously, these checks were only done in non-ghost expressions (historically, it seems the code that performs these checks was designed for checking `(==)`, which applies only in ghost expressions). This PR adds the checks also specifications (which are ghost) and default expressions for parameters). The new test file `git-issue-4926.dfy` reports 38 errors, whereas before this PR, Dafny reported only 8. It also extracts the code for these checks into a separate file, `TypeCharacteristicChecker.cs` (in addition to the existing file `CheckTypeCharacteristics_Visitor`). Fixes #4926 <small>By submitting this pull request, I confirm that my contribution is made under the terms of the [MIT license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small> --------- Co-authored-by: Stefan Zetzsche <120379523+stefan-aws@users.noreply.github.com>
For the record, here's an example that (before the bug fix) gave a surprising verification: predicate True<A>(a: A) {
true
}
ghost predicate TypeIsEmpty<A(!new)>() {
!exists a: A :: True(a)
}
class Cell { }
method Test() returns (c: Cell)
requires TypeIsEmpty<Cell>()
ensures TypeIsEmpty<Cell>()
{
c := new Cell;
}
method False()
requires TypeIsEmpty<Cell>()
ensures false
{
var c := Test();
assert True(c);
} Method |
Dafny version
4.4.0
Code to produce this issue
Command to run and resulting output
What happened?
The type parameter of function
F
is declared asA(!new)
, which restricts it to types that do not contain references. Thus, the callF<Cell>()
should be flagged as illegal, but it isn't.Curiously, Dafny does flag the assertion, if uncommented, as illegal. So, it seems this check is just missing in the postcondition (or perhaps in specifications in general).
Here is another test example:
What type of operating system are you experiencing the problem on?
Mac
The text was updated successfully, but these errors were encountered: