-
Notifications
You must be signed in to change notification settings - Fork 7
Adding a check to avoid recursive type definitions #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rodrigogribeiro
wants to merge
11
commits into
main
Choose a base branch
from
no-recursion-on-types
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3086494
Adding a check to avoid recursive type definitions
rodrigogribeiro 2a7a4dc
Fixing by allowing recursion through phantom type arguments.
rodrigogribeiro d5ef741
Fixing test cases.
rodrigogribeiro 646f451
Fixes on recursive check on types
rodrigogribeiro 9854d92
Ormulu format.
rodrigogribeiro cb18cfe
Merge branch 'main' into no-recursion-on-types
rodrigogribeiro 7dbaa3e
rebasing
rodrigogribeiro d60ce4b
eliminating unused code
rodrigogribeiro 213c2bd
Adding test on recursive types
rodrigogribeiro 91b183f
Fixes suggested by YNak
rodrigogribeiro 4797d14
Ormolu formatting.
rodrigogribeiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,16 +1,30 @@ | ||
| contract EitherModule { | ||
| data memory(a) = memory(word); | ||
| data Either(a,b) = Left(a) | Right(b); | ||
| data List(a) = Nil | Cons(a,List(a)); | ||
| data List(a) = Nil | Cons(a, memory(List(a))); | ||
|
|
||
| function lefts(xs) { | ||
| forall a b . function lefts(xs : List (Either(a,b))) -> List(a) { | ||
| match xs { | ||
| | Nil => return Nil ; | ||
| | Cons(y,ys) => | ||
| match y { | ||
| | Left(z) => return Cons(z,lefts(ys)) ; | ||
| | Right(z) => return lefts(ys) ; | ||
| | Left(z) => return Cons(z,storeList(lefts(loadList(ys)))) ; | ||
| | Right(z) => return lefts(loadList(ys)) ; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| forall a . function loadList(xs : memory(List(a))) -> List(a) { | ||
| match xs { | ||
| | memory(_) => return Nil ; | ||
| } | ||
| } | ||
|
|
||
| forall a . function storeList (xs : List(a)) -> memory(List(a)) { | ||
| return memory(0); | ||
| } | ||
|
|
||
| function main () -> word { | ||
| return 42; | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
| data memory(a) = memory(word); | ||
| data Box(a) = Box(memory(a)); | ||
| data Rec = Rec(Box(Rec)); |
This file contains hidden or 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,9 @@ | ||
| contract A { | ||
| data T = MkT(U); | ||
| data U = MkU(word); | ||
| } | ||
|
|
||
| contract B { | ||
| data T = MkT2(word); | ||
| data U = MkU2(T); | ||
| } |
This file contains hidden or 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 @@ | ||
| data memory(a) = memory(word); | ||
|
|
||
| data List(a) = Nil | Cons(a, memory(List(a))); |
This file contains hidden or 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,9 @@ | ||
| -- Direct recursion: Nat refers to itself in the Succ constructor. | ||
| -- Expected: type checker rejects with "Recursive data type detected". | ||
| data Nat = Zero | Succ(Nat); | ||
|
|
||
| contract RecursiveTypeDirect { | ||
| function main() -> Nat { | ||
| Zero | ||
| } | ||
| } |
This file contains hidden or 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,10 @@ | ||
| -- Mutual recursion: Even refers to Odd and Odd refers to Even. | ||
| -- Expected: type checker rejects with "Recursive data type detected". | ||
| data Even = Zero | SuccE(Odd); | ||
| data Odd = SuccO(Even); | ||
|
|
||
| contract RecursiveTypeMutual { | ||
| function main() -> Even { | ||
| Zero | ||
| } | ||
| } |
This file contains hidden or 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 @@ | ||
|
|
||
| type Ref = T; | ||
| data T = Mk(Ref); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.