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

Do not include collection expression conversion to nullable value type in ClassifyStandardImplicitConversion() #74251

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

cston
Copy link
Member

@cston cston commented Jul 3, 2024

Do not include collection expression conversions to nullable value types in ClassifyStandardImplicitConversion().

User-defined conversions should not be considered in collection expression conversions. And it looks like the scenarios were not supported previously, even though ClassifyStandardImplicitConversion() allowed user-defined conversions from nullable value types, because Binder.ConvertCollectionExpression() created a BoundCollectionExpression with HasErrors=true when the conversion was a user-defined conversion rather than a collection expression conversion.

In some cases, such as the repro from #74185 with 17.8, a specific error was reported for the target type: CS1061: 'Container<object>' does not contain a definition for 'Add'

In other cases, no diagnostic was reported from binding, but the invalid BoundCollectionExpression would cause emit to fail with a general error: CS7038: Failed to emit module: Unable to determine specific cause of the failure.

Now, the user-defined conversion is ignored in ClassifyStandardImplicitConversion(), and an error should be reported for the target type in all cases.

Fixes #74185

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 3, 2024
@cston cston marked this pull request as ready for review July 3, 2024 06:52
@cston cston requested a review from a team as a code owner July 3, 2024 06:52
Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 1)

@cston cston requested review from 333fred and a team July 9, 2024 14:12
@cston cston merged commit 4c02e37 into dotnet:main Jul 11, 2024
24 checks passed
@cston cston deleted the 74185 branch July 11, 2024 16:55
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 11, 2024
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.

CS7038: Failed to emit module if new collection syntax is used with an implicit ImmutableArray operator.
3 participants