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

Exhaustiveness check quacked on nested deconstruction #55719

Open
WhiteBlackGoose opened this issue Aug 19, 2021 · 6 comments
Open

Exhaustiveness check quacked on nested deconstruction #55719

WhiteBlackGoose opened this issue Aug 19, 2021 · 6 comments
Assignees
Milestone

Comments

@WhiteBlackGoose
Copy link

Version Used:

Mine is 6.0.100-preview.6.21355.2, not sure which one is on sharplab, but it's also reproducable there.

Steps to Reproduce:

Create a record of two props with a property being this record. Switch over null and over (var ..., (var ..., tail):

#nullable enable

LinkedList<(T, T)>? GroupBy2<T>(LinkedList<T>? list)
    => list switch    // No warning
    {
        null => null,
        (var h1, (var h2, var tail)) => new((h1, h2), GroupBy2(tail))
        // no warning but try to pass new LinkedList<int>(5, null) and get a SwitchExpressionException
    };

public sealed record LinkedList<T>(T Head, LinkedList<T>? Tail);

Expected Behavior:

Warning, because (_, null) case not covered

Actual Behavior:

No warning.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 19, 2021
@Youssef1313
Copy link
Member

Few observations:

The warning is produced if one the following changes are made:

@alrz
Copy link
Member

alrz commented Aug 19, 2021

Possible duplicate of #52714

@333fred
Copy link
Member

333fred commented Aug 19, 2021

Definitely a duplicate.

@333fred 333fred closed this as completed Aug 19, 2021
@Youssef1313
Copy link
Member

@333fred The behavior I'm observing (stated in #55719 (comment)) doesn't seem to apply on the other issue. Is the reason known? If not, I think it's worth keeping this one open and see if a fix for #52714 also fixes this one or not.

@333fred
Copy link
Member

333fred commented Aug 19, 2021

Ah, you're right Youssef, this is not a duplicate.

@333fred 333fred reopened this Aug 19, 2021
@RikkiGibson
Copy link
Contributor

RikkiGibson commented Aug 19, 2021

We do expect a warning here because in this scenario the nullable context is enabled. I wouldn't particularly expect a fix for this to change the behavior in #52714.

@jcouv jcouv added Feature - Pattern Matching Pattern Matching Feature - Nullable Reference Types Nullable Reference Types labels Aug 23, 2021
@jaredpar jaredpar added Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 24, 2021
@jaredpar jaredpar added this to the 17.1 milestone Aug 24, 2021
@jcouv jcouv self-assigned this Oct 20, 2021
@jcouv jcouv modified the milestones: 17.1, 17.2 Feb 4, 2022
@jcouv jcouv modified the milestones: 17.2, 17.3 May 13, 2022
@jaredpar jaredpar modified the milestones: 17.3, Backlog Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

7 participants