forked from dafny-lang/dafny
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use Downcast for let RHS and for function body
Fixes dafny-lang#5597
- Loading branch information
1 parent
434e3fb
commit 5502bff
Showing
4 changed files
with
65 additions
and
3 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
51 changes: 51 additions & 0 deletions
51
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.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,51 @@ | ||
// RUN: %testDafnyForEachCompiler "%s" | ||
|
||
method Main() { | ||
var n: set<Number> := {}; | ||
var s: set<Integer>; | ||
s := DoItWithAssignment(n); | ||
print |s|, " "; | ||
s := DoItWithPlainLet(n); | ||
print |s|, " "; | ||
s := DoItWithOptimizedLet(n); | ||
print |s|, " "; | ||
s := DoItViaFunctionBodyResult(n); | ||
print |s|, "\n"; | ||
} | ||
|
||
trait Number { | ||
const value: int | ||
} | ||
|
||
class Integer extends Number { | ||
constructor(value: int) { | ||
this.value := value; | ||
} | ||
} | ||
|
||
method DoItWithAssignment(numbers: set<Number>) returns (integers00: set<Integer>) | ||
requires |numbers| == 0 | ||
{ | ||
integers00 := numbers; | ||
} | ||
|
||
function DoItWithPlainLet(numbers: set<Number>): set<Integer> | ||
requires |numbers| == 0 | ||
{ | ||
{} + | ||
var integers11: set<Integer> := numbers; | ||
integers11 | ||
} | ||
|
||
function DoItWithOptimizedLet(numbers: set<Number>): set<Integer> | ||
requires |numbers| == 0 | ||
{ | ||
var integers22: set<Integer> := numbers; | ||
integers22 | ||
} | ||
|
||
function DoItViaFunctionBodyResult(numbers: set<Number>): set<Integer> | ||
requires |numbers| == 0 | ||
{ | ||
numbers | ||
} |
1 change: 1 addition & 0 deletions
1
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.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 @@ | ||
0 0 0 0 |