Fix a bunch of problems with SILGen of tuples with pack expansions #64231
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 are two main bugs being fixed in this PR:
The first is that the
RValue
abstraction in SILGen was trying to eagerly expand these tuples, which really doesn't work — not only are the instructions it's using not really appropriate for these tuples, there's also just no simple value representation of a pack expansion that can stand in here. Maybe in the long term we'll have value representations, but in the short term, the only reasonable choice seems to be to prevent this expansion. I don't hate that anyway; I've never been a fan of the eager expansion.The second is that the way we were binding parameters didn't work for tuples that contain pack expansions. The current CC recursively expands these tuples and passes expansions as value packs, and the parameter-binding code has to glue everything back together as a tuple. That gluing-together did not know about pack expansions and the different code patterns that have to be used with them. So there was quite a bit of infrastructure that needed to be fleshed out here.