-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SE-0408] Enable Pack Iteration #67594
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
Changes from all commits
5832181
42a0666
6ab8310
af56beb
be212ba
f276bd2
b0af0f7
a687032
2348599
48cb330
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -446,6 +446,9 @@ void ForEachStmt::setPattern(Pattern *p) { | |
} | ||
|
||
Expr *ForEachStmt::getTypeCheckedSequence() const { | ||
if (auto *expansion = dyn_cast<PackExpansionExpr>(getParsedSequence())) | ||
return expansion; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to do more checking here or add a bit to the statement to make sure that we are only returning non-null pack expansion expressions iff type-checking was successful. For regular for-in statements type-checker sets There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we might need to rethink the purpose of this method with this feature in mind. The bug where pack iteration was not working in closures had to partially deal with the fact that whoever calls it assumes that the type-checking was successful and we are dealing with a sequence if the method is non-null: 90ca95c#diff-f7b20ead68204a38f1ecf3cd2202f98fbcbfc193e117458b8ce6e612cb8855c7R1893. When we are dealing with a pack expansion, the assumed "sequence" will be non-null (but containing an expansion expr) and we will go into the sequence code path, which is undesired. So the only way to use this method "right" is to check if casting the result into an expansion expression is non-null to make sure that the sequence is null... Which is not obvious at all and we need to fix this. I think I'll put a TODO on it for now |
||
|
||
return iteratorVar ? iteratorVar->getInit(/*index=*/0) : nullptr; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.