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

Local constant declarations can specify const multiple times #6929

Merged
merged 3 commits into from
Nov 21, 2015
Merged

Local constant declarations can specify const multiple times #6929

merged 3 commits into from
Nov 21, 2015

Conversation

leppie
Copy link
Contributor

@leppie leppie commented Nov 20, 2015

Fixes #6761.
Matches behavior for const field declarations.

Side note: There should be a ParseAndValidate that ignores additional errors. Sometimes the extra errors make a test needlessly complex.

Matches behavior for const field declarations.
Add extra test.
@leppie
Copy link
Contributor Author

leppie commented Nov 20, 2015

@dotnet-bot retest prtest/win/dbg/unit64 please

@davkean davkean added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Nov 20, 2015
@davkean
Copy link
Member

davkean commented Nov 20, 2015

tag @dotnet/roslyn-compiler

@davkean
Copy link
Member

davkean commented Nov 20, 2015

okay to test
test eta please

@VSadov
Copy link
Member

VSadov commented Nov 20, 2015

LGTM

@@ -7996,6 +7996,12 @@ private void ParseDeclarationModifiers(SyntaxListBuilder list)
mod = this.AddError(mod, ErrorCode.ERR_BadMemberFlag, mod.Text);
}

// check for duplicates, can only be const
Copy link
Member

Choose a reason for hiding this comment

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

Comments shouldn't be used to break apart if / else blocks. Please move the comment into the else block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jaredpar: Thanks, I wasn't sure about this :) Was just an if initially. Edit: Holy Batman, I just noticed how big that file is!

@jaredpar
Copy link
Member

👍 modulo the style comment.

else if (list.Any(mod.Kind))
{
// check for duplicates, can only be const
mod = this.AddError(mod, ErrorCode.ERR_TypeExpected, mod.Text);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to report more specific error, i.e. duplicate modifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlekseyTs: Agreed, but I for now I just recreated the behavior of fields. The previous compiler reports a different error if I recall correctly, but for consistency I chose Roslyn's behavior. Edit: I cant seem to replicate the behavior I saw earlier on old compiler. Error was CS1041: Identifier expected, 'const' is a keyword'. (Or perhaps that was another case?)

Copy link
Contributor

Choose a reason for hiding this comment

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

Given that this function is only used to parse a local declaration, I agree that ERR_TypeExpected is in agreement with the language grammar.

@AlekseyTs
Copy link
Contributor

LGTM

@davkean
Copy link
Member

davkean commented Nov 20, 2015

test eta please

@davkean
Copy link
Member

davkean commented Nov 21, 2015

Merging this in, thanks again for another contribution!

davkean added a commit that referenced this pull request Nov 21, 2015
Local constant declarations can specify const multiple times
@davkean davkean merged commit 373f503 into dotnet:master Nov 21, 2015
@leppie leppie deleted the issue-6761 branch November 23, 2015 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers cla-already-signed Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants