Skip to content

Commit

Permalink
Remove unnecessary error code
Browse files Browse the repository at this point in the history
  • Loading branch information
cston committed Apr 17, 2023
1 parent c373a36 commit 4ab8b2c
Show file tree
Hide file tree
Showing 18 changed files with 7 additions and 84 deletions.
9 changes: 1 addition & 8 deletions src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2364,14 +2364,7 @@ protected void GenerateImplicitConversionError(
}
case BoundKind.UnconvertedCollectionLiteralExpression:
{
if (targetType is ArrayTypeSymbol { IsSZArray: false })
{
Error(diagnostics, ErrorCode.ERR_CollectionLiteralTargetTypeMultiDimensionalArray, syntax);
}
else
{
Error(diagnostics, ErrorCode.ERR_CollectionLiteralTargetTypeNotConstructible, syntax, targetType);
}
Error(diagnostics, ErrorCode.ERR_CollectionLiteralTargetTypeNotConstructible, syntax, targetType);
return;
}
case BoundKind.AddressOfOperator when targetType.IsFunctionPointer():
Expand Down
3 changes: 0 additions & 3 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -6792,9 +6792,6 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_ImplicitlyTypedCollectionLiteralNoBestType" xml:space="preserve">
<value>No best type found for implicitly-typed collection literal.</value>
</data>
<data name="ERR_CollectionLiteralTargetTypeMultiDimensionalArray" xml:space="preserve">
<value>A collection literal cannot be target typed to a multidimensional array.</value>
</data>
<data name="ERR_EqualityContractRequiresGetter" xml:space="preserve">
<value>Record equality contract property '{0}' must have a get accessor.</value>
</data>
Expand Down
1 change: 0 additions & 1 deletion src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,6 @@ internal enum ErrorCode
ERR_ExpressionTreeContainsCollectionLiteral = 9501,
ERR_CollectionLiteralElementNotImplemented = 9502, // PROTOTYPE: Temporary error until feature has been implemented.
ERR_ImplicitlyTypedCollectionLiteralNoBestType = 9503,
ERR_CollectionLiteralTargetTypeMultiDimensionalArray = 9504,

#endregion

Expand Down
1 change: 0 additions & 1 deletion src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2311,7 +2311,6 @@ internal static bool IsBuildOnlyDiagnostic(ErrorCode code)
case ErrorCode.ERR_ExpressionTreeContainsCollectionLiteral:
case ErrorCode.ERR_CollectionLiteralElementNotImplemented:
case ErrorCode.ERR_ImplicitlyTypedCollectionLiteralNoBestType:
case ErrorCode.ERR_CollectionLiteralTargetTypeMultiDimensionalArray:
return false;
default:
// NOTE: All error codes must be explicitly handled in this switch statement
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1781,12 +1781,12 @@ static void Main()
""";
var comp = CreateCompilation(source);
comp.VerifyEmitDiagnostics(
// (5,23): error CS9504: A collection literal cannot be target typed to a multidimensional array.
// (5,23): error CS9500: Cannot initialize type 'object[*,*]' with a collection literal because the type is not constructible.
// object[,] x = [];
Diagnostic(ErrorCode.ERR_CollectionLiteralTargetTypeMultiDimensionalArray, "[]").WithLocation(5, 23),
// (6,20): error CS9504: A collection literal cannot be target typed to a multidimensional array.
Diagnostic(ErrorCode.ERR_CollectionLiteralTargetTypeNotConstructible, "[]").WithArguments("object[*,*]").WithLocation(5, 23),
// (6,20): error CS9500: Cannot initialize type 'int[*,*]' with a collection literal because the type is not constructible.
// int[,] y = [null, 2];
Diagnostic(ErrorCode.ERR_CollectionLiteralTargetTypeMultiDimensionalArray, "[null, 2]").WithLocation(6, 20));
Diagnostic(ErrorCode.ERR_CollectionLiteralTargetTypeNotConstructible, "[null, 2]").WithArguments("int[*,*]").WithLocation(6, 20));
}

[Fact]
Expand All @@ -1803,9 +1803,9 @@ static void Main()
""";
var comp = CreateCompilation(source);
comp.VerifyEmitDiagnostics(
// (5,20): error CS9504: A collection literal cannot be target typed to a multidimensional array.
// (5,20): error CS9500: Cannot initialize type 'int[*,*]' with a collection literal because the type is not constructible.
// int[,] z = [[1, 2], [3, 4]];
Diagnostic(ErrorCode.ERR_CollectionLiteralTargetTypeMultiDimensionalArray, "[[1, 2], [3, 4]]").WithLocation(5, 20));
Diagnostic(ErrorCode.ERR_CollectionLiteralTargetTypeNotConstructible, "[[1, 2], [3, 4]]").WithArguments("int[*,*]").WithLocation(5, 20));
}

[ConditionalTheory(typeof(CoreClrOnly))]
Expand Down

0 comments on commit 4ab8b2c

Please sign in to comment.