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

False warning: pattern matching on a field doesn't count as a use #52956

Closed
alrz opened this issue Apr 27, 2021 · 3 comments
Closed

False warning: pattern matching on a field doesn't count as a use #52956

alrz opened this issue Apr 27, 2021 · 3 comments
Assignees
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers New Language Feature - Pattern Matching Pattern Matching
Milestone

Comments

@alrz
Copy link
Contributor

alrz commented Apr 27, 2021

class C
{
    C field1 = null;
    public static void Main()
    {        
        _ = new C() is { field1: {} }; // CS0414 (not expected)
    }
}
class C
{
    C field1;
    public static void Main()
    {        
        _ = new C() is { field1: {} }; // CS0169 (not expected)
    }
}

Test plan: #52468

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

I expect there is one or more NoteRead calls are missing in

private void AssignPatternVariables(BoundPattern pattern, bool definitely = true)

@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label May 20, 2021
@jcouv jcouv self-assigned this May 20, 2021
@jcouv jcouv added this to the C# 10 milestone May 20, 2021
@jcouv
Copy link
Member

jcouv commented May 20, 2021

Thanks for finding this. I'm fixing it as part of the extended property patterns.

@jcouv jcouv added 4 - In Review A fix for the issue is submitted for review. and removed 3 - Working labels May 27, 2021
@jcouv jcouv modified the milestones: C# 10, 17.0 May 27, 2021
@jcouv
Copy link
Member

jcouv commented May 27, 2021

Fixed by #53594 in feature branch (planned to merge for 17.0)

@jcouv jcouv closed this as completed May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers New Language Feature - Pattern Matching Pattern Matching
Projects
None yet
Development

No branches or pull requests

3 participants