-
Notifications
You must be signed in to change notification settings - Fork 3
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
vine: allow returns with no expression #73
Merged
+71
−7
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
10372d3
Add null_return example
stevenhuyn c5f61cb
Add empty return test program
stevenhuyn f586d95
Call default value, unit
stevenhuyn 762ac27
Remove old example
stevenhuyn 8d55c1b
Update vine/src/parser.rs
stevenhuyn 27306ad
Make lower_return take a Option<&Expr>
stevenhuyn 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 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,8 @@ | ||
|
||
use std::io::println; | ||
|
||
fn main(io) { | ||
io.println("We should see this"); | ||
return; | ||
io.println("But not this"); | ||
} |
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,31 @@ | ||
|
||
::main { ::no_return::main } | ||
|
||
::no_return::main { | ||
fn(n0 _) | ||
::std::io::println = fn(ref(n0 _) fn(tup(18 tup(tup(87 tup(101 tup(32 tup(115 tup(104 tup(111 tup(117 tup(108 tup(100 tup(32 tup(115 tup(101 tup(101 tup(32 tup(116 tup(104 tup(105 tup(115 n1)))))))))))))))))) n1)) _)) | ||
} | ||
|
||
::std::io::println { | ||
fn(ref(n0 n3) fn(n1 _)) | ||
::std::io::print = fn(ref(n0 n2) fn(n1 _)) | ||
::std::io::print_char = fn(ref(n2 n3) fn(10 _)) | ||
} | ||
|
||
::std::io::print { | ||
fn(ref(n0 n1) fn(tup(n2 tup(n3 _)) _)) | ||
::std::io::print::1 = x(n0 x(n1 x(n2 n3))) | ||
} | ||
|
||
::std::io::print::1 { x(n0 x(n1 x(dup12(?(::std::io::print::3 ::std::io::print::2 x(n0 x(n1 x(n3 n2)))) n3) n2))) } | ||
|
||
::std::io::print::2 { | ||
x(n1 x(n3 x(@sub(1 n4) tup(n0 n5)))) | ||
::std::io::print_char = fn(ref(n1 n2) fn(n0 _)) | ||
::std::io::print::1 = x(n2 x(n3 x(n4 n5))) | ||
} | ||
|
||
::std::io::print::3 { x(n0 x(n0 _)) } | ||
|
||
::std::io::print_char { fn(ref(@io_print_char(char io) io) fn(char _)) } | ||
|
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 @@ | ||
We should see this |
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,15 @@ | ||
|
||
Interactions | ||
Total 397 | ||
Annihilate 215 | ||
Commute 0 | ||
Copy 21 | ||
Erase 44 | ||
Expand 61 | ||
Call 37 | ||
Branch 19 | ||
|
||
Memory | ||
Heap 592 B | ||
Allocated 8_112 B | ||
Freed 8_112 B |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner for
lower_return
to take anOption<Expr>
and just not write to the local if it'sNone
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woah didn't expect that to work. Right now is it undefined behaviour to assign the result of function that returns nothing to a var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, it's just that uninitialized variables are represented with an eraser node, which is the same as an empty tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or, one can think of it as every variable being initialized as an empty tuple