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

Confusing error when assigning result of ref readonly-returning method to a ref local #28653

Open
svick opened this issue Jul 18, 2018 · 0 comments
Labels
Area-Compilers Bug 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

@svick
Copy link
Contributor

svick commented Jul 18, 2018

Version Used: 2.8.2; master from 14 July 2018 (c4189de)

Steps to Reproduce:

Try to assign the result of a ref readonly-returning method to a non-readonly ref local:

class C
{
    void M()
    {
        ref int x = ref Bar();
    }
    
    ref readonly int Bar() => throw null;
}

Actual Behavior:

error CS8329: Cannot use method 'C.Bar()' as a ref or out value because it is a readonly variable

I think this is not a good error message because:

  1. It's not correct: method is not a variable.
  2. It does not explain well what the error is and how to fix it.
@gafter gafter added Area-Compilers Concept-Diagnostic Clarity The issues deals with the ease of understanding of errors and warnings. Bug labels Jul 18, 2018
@gafter gafter added the help wanted The issue is "up for grabs" - add a comment if you are interested in working on it label Aug 27, 2019
@gafter gafter added this to the Backlog milestone Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Bug 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

No branches or pull requests

2 participants