Latest Results
fix(tree-shaking): preserve throwing built-ins in pure-globals fast path
Reviewer caught a real soundness bug: literal args can still trigger
synchronous throws in `Set`/`Map`/`Array`/TypedArray constructors and
`Number`/`Date`. With the previous `TriviallySafeArgs` gate, calls like
`new Set(1)` (TypeError), `new Array(-1)` (RangeError), and
`new Uint8Array(1.5)` (RangeError) were incorrectly classified as pure
and could be tree-shaken away — silently dropping the throw.
Split `ArgGate` into four variants by argument-shape requirement:
* `AnyPureArgs` — callee neither coerces nor throws on values
(e.g. `Boolean(x)`, `Array.isArray(x)`, `Object.is(a, b)`).
* `TriviallySafeArgs` — callee handles every literal safely
(e.g. `String("x")`, `Object("y")`, `Symbol("desc")`).
* `NullishOrNoArgs` — callee throws on non-iterable / non-numeric
values, so only `null`/`undefined`/no-args are safe (e.g.
`new Set()`, `new Map()`, `new Date()`, `new Number()`,
`new Array()`).
* `NullishOrNonNegativeIntLiteral` — `RangeError` on negative,
fractional, or out-of-range lengths; only nullish or `[0, 2^32)`
integer literals pass (e.g. `new Uint8Array(16)`,
`new ArrayBuffer(0)`).
Reclassification:
* `Set`/`Map`/`WeakSet`/`WeakMap`: `NullishOrNoArgs`.
* `Array` (both new and call): `NullishOrNoArgs`.
* `Date`/`Number` (both): `NullishOrNoArgs` (BigInt → ToNumber throws).
* TypedArrays / `ArrayBuffer` / `SharedArrayBuffer`:
`NullishOrNonNegativeIntLiteral`.
* `String`/`Object`: stays `TriviallySafeArgs` (ToString/ToObject
accept any literal incl BigInt).
* `Boolean`: promoted to `AnyPureArgs` in both positions (ToBoolean
never throws and never invokes user code).
* `Symbol` (call only): `TriviallySafeArgs`.
New helpers in `pure_globals.rs`:
* `is_nullish_expr`: null literal / `undefined` ident / `void <safe>`.
* `is_non_negative_int_literal`: finite, integer, `[0, 2^32)`,
handles `+N` UnaryExpr; rejects BigInt, negative, fractional,
NaN/Infinity.
* `check_arg_gate`: dispatches arg-shape check based on gate.
Snapshot test extended with 9 new "MUST be kept" cases covering each
throw category. All cases verified in the regenerated
`treeshaking.snap.txt` — pure forms are wrapped in `null && (…)`,
throwing forms are preserved verbatim.
Unit tests: 25 total (was 16), covering each gate, both positions for
each global, and direct arg-shape checks against synthetic Lit/Num
expressions. Latest Branches
-3%
worktree-ci_size_limit_on_main -3%
-4%
© 2026 CodSpeed Technology