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 #6761

Closed
jskeet opened this issue Nov 13, 2015 · 3 comments
Closed

Local constant declarations can specify const multiple times #6761

jskeet opened this issue Nov 13, 2015 · 3 comments
Milestone

Comments

@jskeet
Copy link

jskeet commented Nov 13, 2015

Roslyn version: 1.0.0.50618

Sample code:

class Test
{
    static void Main()
    {
        const const const bool flag = true;
    }
}

This should lead to a compile-time error as per C# 5 spec section 8.5.2, but it doesn't.

Source: http://stackoverflow.com/questions/33694904

@AdamMaras
Copy link

I'm not immediately opposed to this behavior—I see it as being a good way to communicate to other developers that the value is "really really const" and should never ever be changed.

@leppie
Copy link
Contributor

leppie commented Nov 13, 2015

It detects the error fine on type level, eg:

class Foo {
  const const const bool flag = true;
}

@gafter gafter added this to the 1.2 milestone Nov 15, 2015
@drauch
Copy link

drauch commented Nov 17, 2015

@AdamMaras: Should be consistent with other modifiers though, e.g. readonly (see SO question).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants