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

Creating a value tuple with a non-existent field results in a confusing CS8619 #61462

Closed
Tragetaschen opened this issue May 23, 2022 · 1 comment · Fixed by #61895
Closed
Assignees
Labels
4 - In Review A fix for the issue is submitted for review. Area-Compilers Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@Tragetaschen
Copy link

Version Used:

17.3.0 Preview 1.0

Steps to Reproduce:

public static class S
{
    public const string A = "a";
}

public class C
{
    public (string, string) M()
    {
        return ("a", S.B); // S.B does not exist
    }
}

Expected Behavior:

I expect the error that S.B does not exist and a squiggle just for that. Derived errors should be suppressed.

Actual Behavior:

CS8619 Nullability of reference types in value of type '(string, ? B)' doesn't match target type '(string, string)'.
and then
CS0117 'S' does not contain a definition for 'B'

Notes
CS8619 comes before CS0117 in the Error List and the visible squiggle covers the entire tuple expression.
You need to carefully hover the squiggle to see the actual error.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 23, 2022
@RikkiGibson RikkiGibson added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. labels May 23, 2022
@RikkiGibson
Copy link
Contributor

RikkiGibson commented May 23, 2022

I think this could be addressed by treating an error type as equal to any other type when we do nullable variance checks.

@jcouv jcouv self-assigned this Jun 14, 2022
@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jun 14, 2022
@jcouv jcouv added this to the 17.3 milestone Jun 14, 2022
@jcouv jcouv added the 4 - In Review A fix for the issue is submitted for review. label Jun 15, 2022
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 Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants