Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection expressions: report specific conversion errors from overload resolution #73307

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cston
Copy link
Member

@cston cston commented May 2, 2024

Fixes #73297

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 2, 2024
@cston cston marked this pull request as ready for review May 3, 2024 21:02
@cston cston requested a review from a team as a code owner May 3, 2024 21:02
@cston
Copy link
Member Author

cston commented May 16, 2024

@dotnet/roslyn-compiler, please review.

@RikkiGibson RikkiGibson self-assigned this May 16, 2024
@@ -1231,6 +1231,10 @@ private static bool HadLambdaConversionError(BindingDiagnosticBag diagnostics, A
{
// a diagnostic has been reported by ReportDelegateOrFunctionPointerMethodGroupDiagnostics
}
else if (argument.Kind == BoundKind.UnconvertedCollectionExpression)
{
binder.GenerateImplicitConversionErrorForCollectionExpression((BoundUnconvertedCollectionExpression)argument, parameterType, diagnostics);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! That was easy. :)

{
string source = """
ERROR[] values = [1];
values = [2];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting, and seems reasonable I guess, as an "avoid cascading" behavior? Is this similar to how values = new[] { 2 } would behave?

@RikkiGibson RikkiGibson requested a review from a team May 20, 2024 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collection expression conversion failure should result in element-wise diagnostics
2 participants