camc314 f8e6c6ccf8 fix(packages/codegen): preserve in restriction through yield arguments (#26421)
`packages/codegen` can turn valid JavaScript into unparseable output when a `yield` expression appears in a classic `for` loop initializer and its argument contains an `in` operator.

For example, this input is valid:

```js
function* g(o) {
  for (yield (1 in o); false;);
}
```

The JavaScript printer previously dropped the required grouping:

```js
function* g(o) {
  for (yield 1 in o; false;);
}
```

An unparenthesized `in` is not allowed at this position in a classic `for` initializer. The same problem affects `yield*`, nested yields, and assignments inside the yield argument.

The printer now preserves the parentheses:

```js
function* g(o) {
  for (yield (1 in o); false;);
}
```

The `for` printer already marks its initializer with `CTX_FORBID_IN`, but `printYieldExpression` discarded that context and printed its argument with `CTX_NONE`. The yield dispatch now passes its incoming context to `printYieldExpression`, which forwards only `CTX_FORBID_IN` to the argument when the yield expression is unwrapped. The argument retains its existing `PREC_YIELD` precedence.

When precedence requires parentheses around the entire yield expression, those parentheses already permit `in` inside. The argument context is cleared in that case, avoiding redundant inner parentheses:

```js
// Input
function* g(o) {
  for ((yield (1 in o)) + 1; false;);
}

// Output
function* g(o) {
  for ((yield 1 in o) + 1; false;);
}
```

Both `yield` and `yield*` use this path. Outside a restricted initializer, ordinary yields continue to omit unnecessary grouping: `yield (1 in o)` prints as `yield 1 in o`.

The correction applies to both ordinary and source-map-enabled builds and brings the JavaScript printer in line with the Rust fix in #26413.
2026-09-07 17:47:59 +00:00



Oxc logo


MIT licensed Build Status Code Coverage CodSpeed Badge

Discord chat Playground Website

Oxc

/oʊ ɛks siː/

The Oxidation Compiler is a collection of high-performance tools for JavaScript and TypeScript written in Rust.

Oxc is part of VoidZero's vision for a unified, high-performance toolchain for JavaScript. It powers Rolldown (Vite's bundler) and enables the next generation of ultra-fast development tools that work seamlessly together.

For more information, check out our website at oxc.rs.

* Oxidation is the chemical process that creates rust

🙋 Who's using Oxc?

Rolldown and Nuxt use Oxc for parsing. Rolldown also uses Oxc for transformation and minification. Nova, swc-node, and knip use oxc_resolver for module resolution. Preact, Shopify, ByteDance, and Shopee use oxlint for linting.

See more projects using Oxc →

🔧 Lint or Format a Codebase

  • Lint: Oxlintnpx oxlint@latest
  • Format: Oxfmtnpx oxfmt@latest

🧰 Build Tooling on Top of Oxc

  • Parse JavaScript and TypeScript: Parser
  • Transform TypeScript, JSX, and modern JavaScript: Transformer
  • Minify JavaScript for production builds: Minifier
  • Resolve modules for JavaScript and TypeScript: Resolver

✍️ Contribute

Check out some of the good first issues or ask us on Discord.

See CONTRIBUTING.md for guidance, or read the complete contributing guide on our website →

If you are unable to contribute by code, you can still participate by:

📚 Other Resources

Sponsored By

Our sponsors

📖 License

Oxc is free and open-source software licensed under the MIT License.

Thank you to namespace.so for powering our CI/CD pipelines with fast, free macOS and Linux runners.

Oxc ports or copies code from other open source projects, their licenses are listed in Third-party library licenses.

S
Description
migrate-oxlint: Guide for migrating a project from ESLint to Oxlint. Use when asked to migrate, convert, or switch a JavaScript/TypeScript project's linter from ESLint to…; migrate-oxfmt: Guide for migrating a project from Prettier or Biome to Oxfmt. Use when asked to migrate, convert, or switch a JavaScript/TypeScript project's formatter from…
Readme MIT 551 MiB
Languages
Rust 83.4%
JavaScript 9.4%
TypeScript 7.1%