-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid name clashes with Default method (#6031)
### What was changed? Avoid name clash between user defined and Dafny generated Default method for data types. ### How has this been tested? Add test Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3809.dfy Fixes #3809 <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
b79708e
commit e7e3ed4
Showing
5 changed files
with
33 additions
and
1 deletion.
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
26 changes: 26 additions & 0 deletions
26
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3809.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,26 @@ | ||
// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s" | ||
|
||
module m { | ||
datatype D = A | ||
| B | ||
| C { | ||
static const Default: D := B // This one will be translated as Default_ | ||
method Default_() { // Just to be sure there is no clash: this is translated as Default__ | ||
print "Default_ Method\n"; | ||
} | ||
} | ||
|
||
|
||
|
||
method Main() { | ||
var x := D.Default; | ||
x.Default_(); | ||
match x { | ||
case A => print "A!\n"; | ||
case B => print "B!\n"; | ||
case C => print "C!\n"; | ||
} | ||
print "Hello!\n"; | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3809.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 @@ | ||
Default_ Method | ||
B! | ||
Hello! |