dotnet/roslyn

Should provide more specific error message when cardinality of a tuple literal doesn't match target tuple type.

Open

#11,281 opened on May 12, 2016

View on GitHub
 (5 comments) (0 reactions) (0 assignees)C# (20,414 stars) (4,257 forks)batch import
Area-CompilersBugConcept-Diagnostic ClarityFeature - TuplesLanguage-C#help wanted

Description

        [Fact]
        public void TupleTypeMismatch_01()
        {
            var source = @"
class C
{
    static void Main()
    {
        (int, string) x = (1, ""hello"", 2);
    }
}
" + trivial2uple + trivial3uple;

            CreateCompilationWithMscorlib(source, parseOptions: TestOptions.Regular.WithTuplesFeature()).VerifyDiagnostics(
                // (6,27): error CS0029: Cannot implicitly convert type '(int, string, int)' to '(int, string)'
                //         (int, string) x = (1, "hello", 2);
                Diagnostic(ErrorCode.ERR_NoImplicitConv, @"(1, ""hello"", 2)").WithArguments("(int, string, int)", "(int, string)").WithLocation(6, 27));
        }

Expected: An error message saying cardinality doesn't match.

Contributor guide

Should provide more specific error message when cardinality of a tuple literal doesn't match target tuple type. · dotnet/roslyn#11281 | Good First Issue