-
Notifications
You must be signed in to change notification settings - Fork 4k
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
nameof requires a non-static member in a sub-expression #20600
Comments
I suspect this is not per spec. |
I'm marking as a bug even though I'm not sure whether or not this is the correct behavior (it's either by design or a bug, so I figured this was the right label). |
According to https://github.com/dotnet/csharplang/blob/master/spec/expressions.md#nameof-expressions this should be legal. It is therefore a compiler bug. |
According to https://github.com/dotnet/vblang/blob/master/meetings/2014/LDM-2014-10-23.md (Yes, C# design notes in the VB repo because that's where the meeting was held)... the compiler was correct until @MadsTorgersen wrote a spec that didn't exactly agree. |
Having said that, I like what @MadsTorgersen wrote into the spec and I'm happy to make the compiler do that. |
Fixed in #24761 for dev15.7.x. |
Version Used: 5fbdd5c
Steps to Reproduce:
Expected Behavior: No error.
Actual Behavior:
CS0120: An object reference is required for the non-static field, method, or property 'C.Instance'
The text was updated successfully, but these errors were encountered: