Keep extra parens around unit & tuples in arg pats #17618
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.
Description
Another followup to #16079, et seq.
There are several scenarios where it is impossible to know whether the parentheses are required, or whether they may affect compilation, by looking only at the syntax. I addressed this for invocations in #17012, but not for definitions.
Always keep extra parentheses around
()
in argument patterns.In the absence of additional type information,
(())
(or((()))
, etc.) may be compiled differently from()
when used as an argument pattern in a method definition.(See
unit
elimination logic can lead to unutterable & unimplementable signatures #17611, Parenthesized/double unit literal()
→(())
required in certain scenarios #16254.)Always keep extra parentheses around tuples in argument patterns.
In the absence of additional type information,
((x, y))
(or(((x, y)))
, etc.) may be compiled differently from(x, y)
in argument patterns.Checklist