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: Ability to use .Key as a constant name in datatypes and classes (d…
…afny-lang#4423) This PR fixes dafny-lang#4394 I added the corresponding test. <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: Rustan Leino <[email protected]>
- Loading branch information
1 parent
6d93ff6
commit fddbdba
Showing
4 changed files
with
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %baredafny verify %args "%s" > "%t" | ||
// RUN: %diff "%s.expect" "%t" | ||
|
||
datatype T = T( | ||
f:map<nat,nat> | ||
) { | ||
const Keys := f.Keys // Used to be an error | ||
} | ||
|
||
codatatype codatatypeT = CT( | ||
f:map<nat,nat> | ||
) { | ||
const Keys := f.Keys // Used to be an error | ||
} | ||
|
||
type opaqueT { | ||
const f: map<nat, nat> | ||
const Keys := f.Keys | ||
} | ||
|
||
newtype newT = x: int | true { | ||
const f: map<nat, nat> := map[] | ||
const Keys := f.Keys | ||
} | ||
|
||
class C { | ||
const Keys: set<nat> | ||
|
||
constructor(f:map<nat,nat>) { | ||
this.Keys := f.Keys; | ||
} | ||
} |
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 1 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 @@ | ||
Ability to use .Key as a constant name in datatypes and classes |