Fix convert to named parameters rest parameter tuple #30286
Merged
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.
Fixes #30264.
This PR also restricts the availability of the named parameters refactor. The refactor will only be offered in a function with a rest parameter if the type of the rest parameter is either an array type or a tuple type. This is necessary because if a rest parameter is an array, the refactor needs to initialize the corresponding variable to preserve semantics:
becomes:
If the rest parameter has a tuple type, then the parameter is not optional and providing an initializer is not necessary.
But in other cases it might not be possible to determine if the empty array initializer should be added (and adding the empty array as initializer might not even type check):