Skip to content
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

Allow deconstruction of 'default' literal #25562

Merged
merged 1 commit into from
Mar 24, 2018

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Mar 17, 2018

This language change needs to be confirmed with LDM, but I think it would make sense to allow (and give default the type from the left-hand-side). This would be consistent with default being allowed in tuple equality ((1, 2) == default).

Relates to discussion: dotnet/csharplang#1358

Customer scenario

(int i, string j) = default; // error CS8131: Deconstruct assignment requires an expression with a type on the right-hand-side.
(i, s) = default; // error CS8131: Deconstruct assignment requires an expression with a type on the right-hand-side.
With this PR, this change becomes allowed.

Bugs this fixes

Fixes #25559

Workarounds, if any

You could write (default, default) instead.

Risk

Performance impact

Low. The only change is to extend the logic to fix the type of tuple literals in deconstructions to also fix the type of default literal.

Is this a regression from a previous update?

No. This is a minor language feature.

Tagging @gafter

@jcouv jcouv added this to the 15.7 milestone Mar 17, 2018
@jcouv jcouv self-assigned this Mar 17, 2018
@jcouv jcouv requested a review from a team as a code owner March 17, 2018 21:33
@jcouv jcouv added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Mar 17, 2018
@alrz
Copy link
Contributor

alrz commented Mar 17, 2018

linking to #21232 (would be nice to consider that in lowering)

jcouv added a commit to jcouv/dotnet-ci that referenced this pull request Mar 20, 2018
@jcouv jcouv changed the base branch from dev15.7.x to features/decon-default March 20, 2018 20:24
@jcouv jcouv removed the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Mar 20, 2018
@jcouv jcouv modified the milestones: 15.7, 16.0 Mar 20, 2018
Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jcouv
Copy link
Member Author

jcouv commented Mar 23, 2018

test windows_debug_unit64_prtest please

@jcouv
Copy link
Member Author

jcouv commented Mar 23, 2018

test windows_debug_unit64_prtest please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants