-
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
Unable to compile constant declaration with self-referencing nameof expression #40
Comments
This works fine in Visual Studio 2015 Preview (CTP 4). Did something change? |
Hm, I'm checking this with 08 of January 'master' branch: |
Yep, it works in CTP4: http://tryroslyn.azurewebsites.net/#b:releases-Dev14CTP4/MYGwhgzhAEDC0G8BQ1XWAewHYQC7TwCcBLLAc2gDloBeaLMAWwFMMAzACkoEoBuJAL5AAA==
Also works in CTP4, but fails to compile with current 'master' |
I wonder why it no longer works. I don't see the usefulness of this, but it should work. |
😄 And after saying that, while maintaining an application with SQL concatenations all over the place, I created constants for the table names to have Visual Studio track its usage for me. But even that wasn't that literal. Well, that beats tostringuing an enum all over the place. |
@sharwell The spec and implementation of nameof() changed since CTP 4. It used to be a custom syntax and we used to use lookup, but that made the lookup rules complicated and inconsistent because of the custom syntax. The argument is now syntactically an expression and we simply bind it. This error is a consequence of binding the name of the constant in the context of the constant's own initializer. |
but will it be updated to handle such cases? I am also affected by this. 2015-02-14 1:45 GMT+01:00 Neal Gafter notifications@github.com:
|
@Przemyslaw-W As soon as we integrate pull request #503 this bug will be fixed. |
@Przemyslaw-W fixed now. |
Great, thanks :) 2015-02-16 21:09 GMT+01:00 Neal Gafter notifications@github.com:
|
Assigning to @AlekseyTs for verification. |
Verified |
Currently this code won't compile because of:
But there is no actual circular reference in evaluation of constant value.
I'm expecting this code to compile fine and constant
N
to have value"N"
.The text was updated successfully, but these errors were encountered: