Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

RikkiGibson
Copy link
Member

@RikkiGibson RikkiGibson commented Oct 8, 2025

Related to #77827

@CyrusNajmabadi haven't looked at your latest changes yet, but, wanted to make sure this test was preserved.

I think it would be reasonable to permit ref struct element type when CollectionExpressionTypeKind.ImplementsIEnumerable is used, and block it otherwise. I am suggesting this because this is the only way we know it can work today, and, if something changed from under us to make one of the other type kinds "start working", it feels like manual intervention would still be needed. (i.e., we would need to determine whether it's possible for us to generate code with reasonable semantics, and decide whether to permit or continue blocking.) That is better than potentially being hit by the same "generate bad IL" issue as IEnumerable<ReadOnlySpan<int>>, but for some different type.

It would also be reasonable to block it for all type kinds, though, until we see a more compelling use case.

@RikkiGibson RikkiGibson marked this pull request as ready for review October 9, 2025 20:50
@RikkiGibson RikkiGibson requested a review from a team as a code owner October 9, 2025 20:50
{
ReadOnlySpan<int> span3 = [3];
ReadOnlySpan<int> span4 = [4];
SpanCollection<ReadOnlySpan<int>> spans2 = [span3, span4];
Copy link
Member Author

Choose a reason for hiding this comment

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

Should add a test to ensure that this collection can't be returned. I don't recall if we have a spec rule that makes this do the right thing for ref struct collection types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.