dotnet/roslyn

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

Open

#11,281 创建于 2016年5月12日

在 GitHub 查看
 (5 评论) (0 反应) (0 负责人)C# (4,257 fork)batch import
Area-CompilersBugConcept-Diagnostic ClarityFeature - TuplesLanguage-C#help wanted

仓库指标

Star
 (20,414 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

        [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.

贡献者指南