Skip to content

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #79337

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner July 12, 2025 07:26
{
var containsStackAlloc = initializer
.DescendantNodesAndSelf(descendIntoChildren: node => node is not AnonymousFunctionExpressionSyntax)
.Any(node => node.IsKind(SyntaxKind.StackAllocArrayCreationExpression));
Copy link
Member Author

Choose a reason for hiding this comment

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

this was a case where we were too aggressive in bailing out. We really only need to bail out for exactly one form. The rest are fine. In other words, only Span<X> x = stackalloc X[...]; cannot be converted to var. any other use of stackalloc on the rhs (including just wrapping it in parens) is fine, as the compiler/lang always treats that as Span<>

@CyrusNajmabadi
Copy link
Member Author

@JoeRobich ptal.

@CyrusNajmabadi CyrusNajmabadi merged commit 985e376 into dotnet:main Jul 14, 2025
26 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the useVarSpan branch July 14, 2025 17:02
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 14, 2025
@RikkiGibson RikkiGibson modified the milestones: Next, 18.0 P1 Aug 19, 2025
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.

IDE0007 not reported when resolved type is Span<T>
3 participants