-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for detecting complete assignments in constructor and panic i…
…f unassigned
- Loading branch information
1 parent
b5950ba
commit f2d7eb8
Showing
8 changed files
with
553 additions
and
484 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
36 changes: 36 additions & 0 deletions
36
Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/classes-relax.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,36 @@ | ||
// NONUNIFORM: Rust does not support relaxed definite assignment | ||
// RUN: %exits-with 3 %baredafny run --target=rs --relax-definite-assignment "%s" > "%t" | ||
// RUN: %diff "%s.wrong.expect" "%t" | ||
// RUN: %baredafny run --target=rs "%s" > "%t" | ||
// RUN: %diff "%s.expect" "%t" | ||
|
||
datatype D = D(value: int) | ||
|
||
class Y { | ||
var c: int | ||
const d: D | ||
constructor(c: int) ensures this.c == c && d.value == c { | ||
this.c := c; | ||
if c == 1 { | ||
this.d := D(1); | ||
} else { | ||
this.d := D(c); | ||
} | ||
} | ||
|
||
constructor Two(c: int, b: bool) ensures this.c == c && d.value == c | ||
requires b | ||
{ | ||
this.c := c; // d not assigned, compilation error. | ||
if b { | ||
this.d := D(c); | ||
} | ||
// This will emit a conditional panick but Dafny will prove it's unreachable | ||
} | ||
} | ||
|
||
method Main() { | ||
var y := new Y(1); | ||
var y2 := new Y.Two(1, true); | ||
print "Instantiation successful"; | ||
} |
3 changes: 3 additions & 0 deletions
3
Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/classes-relax.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,3 @@ | ||
|
||
Dafny program verifier finished with 3 verified, 0 errors | ||
Instantiation successful |
3 changes: 3 additions & 0 deletions
3
Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/classes-relax.dfy.wrong.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,3 @@ | ||
|
||
Dafny program verifier finished with 3 verified, 0 errors | ||
(0,-1): Error: Microsoft.Dafny.UnsupportedInvalidOperationException: The Rust compiler does not support `--relax-definite-assignment` |