-
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
Conversation
vine/src/compile/build_stages.rs
Outdated
ExprKind::Return(r) => self.lower_return(r), | ||
ExprKind::Return(None) => { | ||
let unit = Expr { span: Span::NONE, kind: ExprKind::Tuple(vec![]) }; | ||
self.lower_return(&unit) |
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 an Option<Expr>
and just not write to the local if it's None
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
Co-authored-by: T6 <[email protected]>
Should be merged before #72
Addresses a nice to have from #66