Skip to content

[k2] pass const coroutine parameters by const ref where it's safe#1427

Merged
apolyakov merged 1 commit into
masterfrom
apolyakov/k2-coro-args-by-reference
Oct 14, 2025
Merged

[k2] pass const coroutine parameters by const ref where it's safe#1427
apolyakov merged 1 commit into
masterfrom
apolyakov/k2-coro-args-by-reference

Conversation

@apolyakov
Copy link
Copy Markdown
Contributor

In certain scenarios, it is safe for coroutines to accept arguments by reference. This change allows the code generator to produce user-defined coroutines with reference parameters. The rationale behind this decision is that all await points are encapsulated within runtime functions, which are implemented with safety in mind.

This PR also updates several runtime functions to accept arguments by const &. An additional // SAFETY comment has been added to explain why this change is considered safe.

@apolyakov apolyakov added this to the next milestone Oct 14, 2025
@apolyakov apolyakov self-assigned this Oct 14, 2025
@apolyakov apolyakov added compiler Feature related to compiler k2 Affects compiler or runtime in K2 mode labels Oct 14, 2025
@apolyakov apolyakov force-pushed the apolyakov/k2-coro-args-by-reference branch from ad33705 to d11ca38 Compare October 14, 2025 09:49
@apolyakov apolyakov force-pushed the apolyakov/k2-coro-args-by-reference branch from d11ca38 to 8fb5e82 Compare October 14, 2025 14:48
@apolyakov apolyakov merged commit eb28b1b into master Oct 14, 2025
7 checks passed
@apolyakov apolyakov deleted the apolyakov/k2-coro-args-by-reference branch October 14, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler Feature related to compiler k2 Affects compiler or runtime in K2 mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants