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

Do not use declared constant's value inside a nameof() expression #503

Merged
merged 1 commit into from
Feb 16, 2015

Conversation

gafter
Copy link
Member

@gafter gafter commented Feb 14, 2015

Fixes #40

@gafter
Copy link
Member Author

gafter commented Feb 14, 2015

I also changed all of the tabs in SourceLocalSymbol to spaces.

@gafter
Copy link
Member Author

gafter commented Feb 14, 2015

@VladimirReshetnikov @VSadov Can you please review this?

@gafter gafter self-assigned this Feb 14, 2015
@gafter gafter added Area-Compilers 4 - In Review A fix for the issue is submitted for review. labels Feb 14, 2015
@gafter gafter added this to the 1.0-rc2 milestone Feb 14, 2015
@gafter
Copy link
Member Author

gafter commented Feb 14, 2015

@Jenkins test this please

@gafter
Copy link
Member Author

gafter commented Feb 14, 2015

To: @AlekseyTs @agocke @VSadov @VladimirReshetnikov @jaredpar

Can a couple of you please take a look?

@@ -5244,7 +5245,7 @@ private static void CombineExtensionMethodArguments(BoundExpression receiver, An

ConstantValue constantValueOpt = null;

if (fieldSymbol.IsConst)
if (fieldSymbol.IsConst && this.EnclosingNameofArgument == null)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning "there is no enclosing nameof expression"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding this as a comment

@agocke
Copy link
Member

agocke commented Feb 16, 2015

Does this need a test in the semantic model?

@gafter
Copy link
Member Author

gafter commented Feb 16, 2015

@agocke What would you like to see tested? Or do you mean the semantic model may need to be adjusted to accomodate the change?

@agocke
Copy link
Member

agocke commented Feb 16, 2015

@gafter Just that the semantic model also successfully binds without diagnostics.

@@ -1138,5 +1138,22 @@ public static void Main(string[] args)
Assert.Equal(CandidateReason.MemberGroup, symbolInfo.CandidateReason);
Assert.Equal(1, symbolInfo.CandidateSymbols.Length);
}

[Fact, WorkItem(40, "github.com/dotnet/roslyn")]
public void ConstInitializerUsingSelf()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add similar test for VB.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing so under #543.

@AlekseyTs
Copy link
Contributor

LGTM. We should have the same test for VB.

gafter added a commit that referenced this pull request Feb 16, 2015
Do not use declared constant's value inside a nameof() expression
@gafter gafter merged commit 08c5fbf into dotnet:master Feb 16, 2015
@gafter gafter deleted the fix40 branch February 16, 2015 20:01
@gafter gafter removed the 4 - In Review A fix for the issue is submitted for review. label Feb 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to compile constant declaration with self-referencing nameof expression
4 participants