-
Notifications
You must be signed in to change notification settings - Fork 747
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
[Parser] Use unreachables to fulfill tuple requirements #6488
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@@ -175,7 +175,7 @@ Result<Expression*> IRBuilder::pop(size_t size) { | |||
CHECK_ERR(packageHoistedValue(*hoisted, size)); | |||
|
|||
auto* ret = scope.exprStack.back(); | |||
if (ret->type.size() == size) { | |||
if (ret->type.size() == size || ret->type == Type::unreachable) { |
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.
From your description I thought this was for tuples, but ret->type.size() == size
can be the case for non-tuples too, can't it? (when size == 1
)
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.
Yes, but since we report the size of Type::unreachable
as 1, this code path was already taken for singular unreachable popped values.
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 see, thanks. Maybe worth a comment?
When we need to pop a tuple and the top value on the stack is unreachable, just pop the unreachable rather than producing a tuple.make. This always produces valid IR since an unreachable is always valid where a tuple would otherwise be expected. It also avoids bloating the parsed IR, since we would previously parse a `tuple.make` where all the children were unreachable in this case.
f64f57d
to
59c021e
Compare
When we need to pop a tuple and the top value on the stack is unreachable, just
pop the unreachable rather than producing a tuple.make. This always produces
valid IR since an unreachable is always valid where a tuple would otherwise be
expected. It also avoids bloating the parsed IR, since we would previously parse
a
tuple.make
where all the children were unreachable in this case.