-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds support for ghost named types and ghost type alias
- Loading branch information
Showing
11 changed files
with
121 additions
and
50 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
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
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
33 changes: 33 additions & 0 deletions
33
src/test/resources/regressions/features/ghost_type/ghost-type-fail01.gobra
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,33 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
// checks that fields of a ghost struct type as treated as ghost fields | ||
|
||
package GhostNamedTypeFail01 | ||
|
||
ghost type GhostStruct struct { | ||
f int | ||
} | ||
|
||
ghost type GhostIntDef int | ||
ghost type GhostIntAlias = int | ||
|
||
func foo(ghost s GhostStruct) { | ||
s.f = 42 | ||
//:: ExpectedOutput(type_error) | ||
identity(s.f) | ||
} | ||
|
||
func identity(input int) int { | ||
return input | ||
} | ||
|
||
//:: ExpectedOutput(type_error) | ||
func bar1(i GhostIntDef) { // i must be a ghost parameter | ||
i = 42 | ||
} | ||
|
||
//:: ExpectedOutput(type_error) | ||
func bar2(i GhostIntAlias) { // i must be a ghost parameter | ||
i = 42 | ||
} |
24 changes: 24 additions & 0 deletions
24
src/test/resources/regressions/features/ghost_type/ghost-type-simple01.gobra
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,24 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
package GhostNamedTypeSimple01 | ||
|
||
ghost type GhostStruct struct { | ||
f int | ||
} | ||
|
||
ghost type GhostIntDef int | ||
ghost type GhostIntAlias = int | ||
|
||
func foo(ghost s GhostStruct) { | ||
s.f = 42 | ||
assert s.f == 42 | ||
} | ||
|
||
func bar1(ghost i GhostIntDef) { | ||
i = 42 | ||
} | ||
|
||
func bar2(ghost i GhostIntAlias) { | ||
i = 42 | ||
} |