Skip to content

Generator: next(value?: TNext) again (merge after TypeScriptCompiler #984) - #117

Merged
ASDAlexander77 merged 1 commit into
mainfrom
generator-next-value-2
Nov 22, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
generator-next-value-2

Conversation

@ASDAlexander77

@ASDAlexander77 ASDAlexander77 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Generator.next is declared next: (value?: TNext) => IterateResult<T> again, so g.next(value) type-checks through the library's Generator. #116 had to remove this: an Iterable's next() called a Generator's next(value?) as it was, and wasm trapped with "function signature mismatch" in iteration_types.ts.

Merge after TypeScriptCompiler #984. With #984 the compiler wraps a Generator passed as an Iterable/Iterator in a generated generator that calls next() and re-yields, so the two signatures never meet. TypeScriptCompiler's CI builds this repo's main: merged before #984, this would bring the wasm trap back there.

tests/generator_next_return.ts again covers next(value), plus a Generator<number, void, number> passed as an Iterable<number>.

Checked locally, with the #984 compiler:

  • tests.ps1 release: everything passes under gc (249/250, 1 skipped), rc (244, 6 skipped), none (245, 5 skipped) and own (236, 14 skipped), compiled and JIT.
  • The wasm32 DefaultLib suite (debug): rc 243, none 243 and own 235 passed, 0 failed, including iteration_types.ts.

This repo's own CI tests against the newest compiler release (alpha133), which has neither #984 nor #982/#983, so it can't go green until the next release.

For the reviewer (left to you rather than merged automatically):

  • With this merged, every Generator passed as an Iterable/Iterator goes through the compiler's adapter generator, with one extra layer of next() calls. Under -mm=own the adapter keeps (@keeps) the generator it's given, so passing a generator local to an Iterable parameter becomes a move where it was a borrow: using that local after the call is then an error.
  • A Generator<T, R, number> passed as a Generator<T> is adapted the same way (#984 covers it). next(value) through the adapter doesn't reach the source generator.
  • Run here against this branch, with the #984 compiler: the wasm DefaultLib suite for wasm32 and wasm64, debug and release, under rc, none and own. rc and none: 243 passed each; own: 235 passed. No failures. (TypeScriptCompiler's CI can only test this repo's main.)

🤖 Generated with Claude Code

…iler iterates it by an adapter (TypeScriptCompiler #984)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 8f60c3b into main Nov 22, 2026
2 of 10 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.

1 participant