Combine deconstruction assignment and declaration, and support discards #15826
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.
This is merging Neal's recent change in the features/wildcard branch (#15548) back into master.
@dotnet/roslyn-compiler
Customer scenario
This parsing fix addresses various ambiguities that would be backcompat issues once we allow mixing of deconstruction declarations and assignments. Those scenarios still report errors for now.
For instance,
(a < b, c > d, e) = ...;
. Are there 2 or 3 elements on the left?Bugs this fixes:
Fixes #14794
Fixes #14832
Workarounds, if any
No workaround. If we let customers type such code in C#7.0, we can't change how it gets interpreted in a later version.
Risk
Low. The change is mostly limited to deconstruction code paths.
Performance impact
Low. The parsing has actually become more local (less parsing ahead) which should be a minor improvement.
Is this a regression from a previous update?
No.
Root cause analysis:
This is a ripple effect of our decision to rely on declaration expressions, rather than specialized deconstruction syntax.
How was the bug found?
Know work item (listed in work breakdown #14832)