dotnet/roslyn
View on GitHubShould 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
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.