Skip to content

Generator: next() takes no value again (fixes wasm iteration_types trap from #115) - #116

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

ASDAlexander77 merged 1 commit into
mainfrom
generator-next-noarg

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

This fixes a bug I introduced in #115. Since it merged, the compiler's CI fails iteration_types.ts in every wasm DefaultLib leg (all models), with "RuntimeError: null function or function signature mismatch" in sum. That breaks every TypeScriptCompiler PR, including #983.

Cause: #115 declared Generator.next as (value?: TNext) =>, while Iterable.next is () =>. The compiler's interface-to-interface cast notices the different member type but reports it only when the vtable has to be remapped. next is the first slot of both interfaces, so the cast went through unchanged, and an Iterable's next() called a function with a different signature. Wasm checks signatures on indirect calls and traps. Natively the generator read a sent value that was never given.

Fix: Generator.next takes no value again, as before #115. Kept from #115:

  • return? and throw?
  • the lifted own skip in object_dictionary.ts
  • the return()/throw()/array-as-Iterable tests (the next(value) part of generator_next_return.ts is removed)

Declaring next(value) through the library's Generator stays open (TSLANG 153). It needs the compiler to adapt next when a Generator is given to an Iterable.

Checked locally:

  • A self-contained repro of these declarations (a generator with a TNext and with TNext = undefined passed as an Iterable/Iterator, plus return()) runs on wasm32 under own, rc and none, and natively under all four models. With the Generator: next(value?), return?() and throw?(); own object_dictionary lifted; next/return/throw tests #115 declaration it traps on wasm.
  • tests.ps1 release, built with the TypeScriptCompiler #983 compiler: everything passes under gc, rc, none and own, compiled and JIT.
  • The library's wasm suite wasn't run here; there's no wasm build of it on this machine.

This repo's CI tests against alpha133, which predates #982 and #983, so it can't go green until the next compiler release.

🤖 Generated with Claude Code

…s, (value?) => called as () => was another signature (wasm: iteration_types.ts trapped)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 5b72075 into main Nov 22, 2026
1 of 9 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