-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Correct cast of EnclosingClass (#4954)
This PR causes 5 kinds of crashes that could happen when a function/method (with a specification) of a trait was overridden in an abstract type. Fixes #4952 <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>
- Loading branch information
1 parent
b6f7b96
commit 31da6b9
Showing
5 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4952.dfy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// RUN: %testDafnyForEachResolver "%s" -- --general-traits=datatype | ||
|
||
trait A<K> { | ||
function FunctionRequires(): bool | ||
requires true | ||
function FunctionReads(): bool | ||
reads {} | ||
decreases 2 | ||
function FunctionEnsures(): bool | ||
ensures true | ||
|
||
method MethodRequires() | ||
requires true | ||
method MethodEnsures() | ||
ensures true | ||
} | ||
|
||
type B extends A<string> { | ||
// Each of the following 5 override checks once caused a crash, because those checks | ||
// were not expecting the overrides to be found in an abstract type. | ||
|
||
function FunctionRequires(): bool | ||
function FunctionReads(): bool | ||
decreases 2 | ||
function FunctionEnsures(): bool | ||
|
||
method MethodRequires() | ||
method MethodEnsures() | ||
} |
2 changes: 2 additions & 0 deletions
2
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-4952.dfy.expect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
Dafny program verifier finished with 6 verified, 0 errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix crash when a function/method with a specification is overridden in an abstract type. |