Skip to content

Generator: next(value?), return?() and throw?(); own object_dictionary lifted; next/return/throw tests - #115

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

ASDAlexander77 merged 1 commit into
mainfrom
generator-next-value

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

The library side of TSLANG 153. Merge after a compiler release that includes TypeScriptCompiler #982 and #983. This repo's CI tests against the newest released compiler (alpha133 today), which predates both, so until that release the own legs and the new tests will fail here.

  • Generator<T, TReturn, TNext>:
    • next(value?: TNext): the value is what the yield that resumes evaluates to.
    • Optional return?(value) and throw?(e): a generator declared to return a Generator has them. Under -mm=own, return() exists only for a T that owns nothing.
    • They are fields of a function type like next, not methods: a method shifts the vtable, and a Generator could then no longer be cast to an Iterable.
    • The comment above IteratorResult no longer lists these as "not yet".
  • tests/object_dictionary.ts: the "not own" skip is lifted (the fix is in #982).
  • New tests/generator_next_return.ts (all models): next(value), return(value) running the finally, throw(e) caught in the generator, and an array as an Iterable that is still the caller's afterwards.
  • New tests/iterable_string.ts: a string as an Iterable<string>. It is marked "not own" because a for...of over an Iterable<string> is still refused under own (TSLANG 153).

Checked locally: built with the compiler from #983 (on top of #982). tests.ps1 release passes everything under gc (249/250, 1 skipped), rc (244, 6 skipped), none (245, 5 skipped) and own (236, 14 skipped), compiled and JIT. The debug pass was not run because no debug compiler build exists here.

🤖 Generated with Claude Code

…y test lifted; tests for next(value), return(), throw() and arrays/strings as an Iterable

Needs a compiler with TypeScriptCompiler #982 and #983.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 1f83b1f into main Nov 21, 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