Repository: dotnet/roslyn
File: src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalErrorTests.cs (C#)

Code before:
public class C
{
    public static void Main()
    {
        const int i = 0;
        const const double d = 0;
        const const const long l = 0;
        const readonly readonly readonly const double r = 0;
    }    
}
";
            ParserErrorMessageTests.ParseAndValidate(test,
                // (9,15): error CS0106: The modifier 'readonly' is not valid for this item
                //         const readonly readonly readonly const double r = 0;
                Diagnostic(ErrorCode.ERR_BadMemberFlag, "readonly").WithArguments("readonly").WithLocation(9, 15),
                // (9,24): error CS0106: The modifier 'readonly' is not valid for this item
                //         const readonly readonly readonly const double r = 0;
                Diagnostic(ErrorCode.ERR_BadMemberFlag, "readonly").WithArguments("readonly").WithLocation(9, 24),
                // (9,33): error CS0106: The modifier 'readonly' is not valid for this item
                //         const readonly readonly readonly const double r = 0;
                Diagnostic(ErrorCode.ERR_BadMemberFlag, "readonly").WithArguments("readonly").WithLocation(9, 33)
            );
        }

        [Fact]
        [WorkItem("https://github.com/dotnet/roslyn/issues/32106")]
        public void DuplicateModifiers_NotReportedDuringParsing()
        {
            // Duplicate modifiers for local declarations and local functions should not produce
            // parsing errors. They will be reported during binding.
            var localDeclaration = @"
class C
{
    void M()
    {
        const const int a = 0;
    }
}";
            ParserErrorMessageTests.ParseAndValidate(localDeclaration);

            var localFunction = @"
class C
{
    void M()
    {
        static static void F() {}
    }
}";
            ParserErrorMessageTests.ParseAndValidate(localFunction);

            var typeDeclaration = @"public public class C {}";

Review comment (suggestion):
```suggestion
        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/32106")]
```

Code after:
public class C
{
    public static void Main()
    {
        const int i = 0;
        const const double d = 0;
        const const const long l = 0;
        const readonly readonly readonly const double r = 0;
    }    
}
";
            ParserErrorMessageTests.ParseAndValidate(test,
                // (9,15): error CS0106: The modifier 'readonly' is not valid for this item
                //         const readonly readonly readonly const double r = 0;
                Diagnostic(ErrorCode.ERR_BadMemberFlag, "readonly").WithArguments("readonly").WithLocation(9, 15),
                // (9,24): error CS0106: The modifier 'readonly' is not valid for this item
                //         const readonly readonly readonly const double r = 0;
                Diagnostic(ErrorCode.ERR_BadMemberFlag, "readonly").WithArguments("readonly").WithLocation(9, 24),
                // (9,33): error CS0106: The modifier 'readonly' is not valid for this item
                //         const readonly readonly readonly const double r = 0;
                Diagnostic(ErrorCode.ERR_BadMemberFlag, "readonly").WithArguments("readonly").WithLocation(9, 33)
            );
        }

        [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/32106")]
        public void DuplicateModifiers_NotReportedDuringParsing()
        {
            // Duplicate modifiers for local declarations and local functions should not produce
            // parsing errors. They will be reported during binding.
            var localDeclaration = """
                class C
                {
                    void M()
                    {
                        const const int a = 0;
                    }
                }
                """;
            ParserErrorMessageTests.ParseAndValidate(localDeclaration);

            var localFunction = """
                class C
                {
                    void M()
                    {
                        static static void F() {}
                    }
                }
                """;
            ParserErrorMessageTests.ParseAndValidate(localFunction);