dotnet/roslyn
Auf GitHub ansehenShould provide more specific error message when cardinality of a tuple literal doesn't match target tuple type.
Open
#11.281 geöffnet am 12. Mai 2016
Area-CompilersBugConcept-Diagnostic ClarityFeature - TuplesLanguage-C#help wanted
Repository-Metriken
- Stars
- (20.414 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (256 gemergte PRs in 30 T)
Beschreibung
[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.