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.
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5521.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,73 @@ | ||
// RUN: %testDafnyForEachResolver --expect-exit-code=4 "%s" | ||
|
||
module WithoutWitnessClause { | ||
type Empty = x: int | false witness * | ||
|
||
newtype NewEmpty = Empty // error: the default-witness 0 is not a witness | ||
|
||
method OperateOnNewEmpty(x: NewEmpty) | ||
ensures false | ||
{ | ||
var y: Empty := x as Empty; | ||
} | ||
|
||
method Test() { | ||
var x: NewEmpty := *; | ||
OperateOnNewEmpty(x); | ||
print 10 / 0; | ||
} | ||
} | ||
|
||
module WithWitnessClause { | ||
type Empty = x: int | false witness * | ||
|
||
newtype NewEmpty = Empty witness 506 // error: 506 is not a witness | ||
|
||
method OperateOnNewEmpty(x: NewEmpty) | ||
ensures false | ||
{ | ||
var y: Empty := x as Empty; | ||
} | ||
|
||
method Test() { | ||
var x: NewEmpty := *; | ||
OperateOnNewEmpty(x); | ||
print 10 / 0; | ||
} | ||
} | ||
|
||
module WithGhostWitnessClause { | ||
type Empty = x: int | false witness * | ||
|
||
newtype NewEmpty = Empty ghost witness 506 // error: 506 is not a ghost witness | ||
|
||
method OperateOnNewEmpty(x: NewEmpty) | ||
ensures false | ||
{ | ||
var y: Empty := x as Empty; | ||
} | ||
|
||
method Test() { | ||
var x: NewEmpty := *; | ||
OperateOnNewEmpty(x); // error: x is used before it has really been initialized | ||
print 10 / 0; | ||
} | ||
} | ||
|
||
module DeclaredAsPossiblyEmpty { | ||
type Empty = x: int | false witness * | ||
|
||
newtype NewEmpty = Empty witness * | ||
|
||
method OperateOnNewEmpty(x: NewEmpty) | ||
ensures false | ||
{ | ||
var y: Empty := x as Empty; | ||
} | ||
|
||
method Test() { | ||
var x: NewEmpty := *; | ||
OperateOnNewEmpty(x); // error: x is used before it has really been initialized | ||
print 10 / 0; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5521.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,7 @@ | ||
git-issue-5521.dfy(6,10): Error: trying witness 0: result of operation might violate subset type constraint for 'Empty' | ||
git-issue-5521.dfy(24,35): Error: result of operation might violate subset type constraint for 'Empty' | ||
git-issue-5521.dfy(42,41): Error: result of operation might violate subset type constraint for 'Empty' | ||
git-issue-5521.dfy(52,22): Error: variable 'x', which is subject to definite-assignment rules, might be uninitialized here | ||
git-issue-5521.dfy(70,22): Error: variable 'x', which is subject to definite-assignment rules, might be uninitialized here | ||
|
||
Dafny program verifier finished with 6 verified, 5 errors |