Idempotent modifiers in C#
Solution 1:
It's a bug in the compiler - at least in Roslyn version 1.0.0.50618. From section 8.5.2 of the C# 5 specification:
A local-constant-declaration declares one or more local constants.
local-constant-declaration:
const
type constant-declaratorsconstant-declarators:
constant-declarator
constant-declarators,
constant-declaratorconstant-declarator: identifier
=
constant-expression
As you can see, that grammar doesn't allow for const const const bool flag = true;
.
I've filed a bug against Roslyn so that it can get fixed.