Skip to content

Keep Memory locals as Memory in iterators - #114

Merged
virzak merged 2 commits into
zompinc:masterfrom
PetarIsakovic:master
Sep 12, 2026
Merged

virzak merged 2 commits into
zompinc:masterfrom
PetarIsakovic:master

Conversation

@PetarIsakovic

@PetarIsakovic PetarIsakovic commented Jan 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #113

PetarIsakovic and others added 2 commits September 12, 2026 11:32
A Memory local in an iterator may have to hold its value across a
yield return, which a span can't, so it is no longer declared as a
span there. A Memory local passed to a call which isn't being
synchronized keeps its type too, rather than having .Span appended,
since that call still takes the Memory it took before.

Corrects the snapshot for zompinc#113's test, which expected .Span to be
passed to a method taking ReadOnlyMemory.

Generated with Claude Code
@virzak

virzak commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Rebased onto master and added the fix: a Memory local now stays Memory in an iterator, and .Span is only appended when the call is being synchronized. The expected snapshot passed .Span to a method taking ReadOnlyMemory, so it's corrected too.

@virzak virzak changed the title Test Case For ReadOnlyMemory<T> rewriting to ReadOnlySpan<T> across yield Keep Memory locals as Memory in iterators Sep 12, 2026
@virzak
virzak merged commit 34b24d4 into zompinc:master Sep 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReadOnlyMemory<T> rewrites to ReadOnlySpan<T> across yield

2 participants