Skip to content

lexer: yield* is delegation - #309

Merged
shreeve merged 1 commit into
mainfrom
yield-star
Sep 16, 2026
Merged

shreeve merged 1 commit into
mainfrom
yield-star

Conversation

@shreeve

@shreeve shreeve commented Sep 16, 2026

Copy link
Copy Markdown
Owner

Summary

yield* now means delegation, the same thing as yield from. A * directly after yield on the same line scans as the delegation token, so yield* other(), yield *other() and yield * other() all emit yield* other(). Until now they compiled to (yield) * other(): a bare yield multiplied by the operand, which yielded undefined and never delegated, with no error.

Unchanged on purpose. (yield) * 2 and yield ** 2 keep their meaning. yield *{a: 1} still yields a Map because *{ is claimed first. yield *= x still rejects. A * that opens the next line stays multiplication, since the retag requires the yield's own line.

One meaning change. yield * 3 used to multiply the sent value by three and now delegates to 3, which throws at runtime. JavaScript reads the spelling the same way.

No grammar change. src/parser.js is byte-identical, the corpus is unchanged, and the three editor grammars already color yield as a keyword and * as an operator. Browser bundle regenerated under Bun 1.4.0.

Test

Eight new rows in async.rip. Language battery 3258 passing, toolchain gates 661 passing, full test:all suite green across all 26 lanes.

A `*` directly after `yield` on the same line scans as the FROM token
that `yield from` produces, so `yield* other()`, `yield *other()` and
`yield * other()` all delegate, which is how JavaScript reads the same
spelling. They used to compile to a bare yield multiplied by the
operand, which yielded undefined and never delegated.

`(yield) * 2` and `yield ** 2` keep their meaning, `*{` still opens a
Map literal ahead of this branch, `yield *= x` still rejects, and a `*`
opening the next line stays multiplication because the retag requires
the yield's own line.

No grammar change: the parser is byte-identical and the corpus is
unchanged. The editor grammars already color yield as a keyword and *
as an operator. The browser bundle is regenerated under the pinned Bun.

Battery: eight rows in async.rip pin the three spellings, the return
value, a generator method, the parenthesized multiply, exponentiation,
the Map literal, and the emitted code.
@shreeve
shreeve merged commit 934b141 into main Sep 16, 2026
2 checks passed
@shreeve
shreeve deleted the yield-star branch September 16, 2026 07:04
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