Skip to content
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
merged 6 commits into from
Oct 24, 2024

Conversation

stevenhuyn
Copy link
Contributor

Should be merged before #72
Addresses a nice to have from #66

ExprKind::Return(r) => self.lower_return(r),
ExprKind::Return(None) => {
let unit = Expr { span: Span::NONE, kind: ExprKind::Tuple(vec![]) };
self.lower_return(&unit)
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Member

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

vine/src/parser.rs Outdated Show resolved Hide resolved
@tjjfvi tjjfvi added this pull request to the merge queue Oct 24, 2024
@tjjfvi tjjfvi removed this pull request from the merge queue due to a manual request Oct 24, 2024
@tjjfvi tjjfvi changed the title vine: Allow returns with no expression vine: allow returns with no expression Oct 24, 2024
@tjjfvi tjjfvi added this pull request to the merge queue Oct 24, 2024
Merged via the queue into VineLang:main with commit 51047e2 Oct 24, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants