github PerryTS/perry v0.5.585

latest releases: v0.5.1182, v0.5.1181, v0.5.1180...
one month ago

Closes #484 (rest-parameter bundling for class method dispatch) + #139 (fast-math opt-in).

#484 — rest-parameter bundling for class methods

`class Builder { with(id, ...args: T extends void ? [] | [void] : [T]) }` (or any `...args` rest pattern on a class method) crashed with `TypeError: Cannot read properties of undefined (reading 'length')`. The conditional rest type was a red herring — even `...args: any[]` would have shown the same gap.

Root cause: codegen's class-method dispatch table only tracked `method_param_counts: HashMap<(class, method), usize>` — no rest-parameter flag. Call sites padded missing args with `TAG_UNDEFINED` (issue #235 path) but never bundled trailing args into a `js_array_alloc(n)` rest array. Free-standing functions had this right via `func_signatures.has_rest` since v0.5.0; class methods didn't.

Fix: parallel `method_has_rest: HashMap<(class, method), bool>` populated alongside `method_param_counts` in `compile_module`, threaded through `CrossModuleCtx` + `FnCtx`, and consulted in `lower_call.rs`'s static-dispatch + virtual-override arm to emit the same `js_array_alloc + js_array_push_f64` sequence the freestanding-call path already uses.

After fix: `b.with(1)` correctly passes `args=[]` (length 0) to the method body.

#139 — fast-math opt-in (parallel work)

Per-instruction LLVM `reassoc + contract` FMF flags on `fadd`/`fsub`/`fmul`/`fdiv`/`frem`/`fneg` are now gated on `--fast-math` CLI flag (also `PERRY_FAST_MATH=1` env, also `"perry": { "fastMath": true }` in package.json). Default OFF means Perry produces bit-exact f64 output with Node on most FP-heavy code; the `scripts/fp_fuzz.mjs` differential fuzzer drops divergence from ~30% → ~6%. New docs page `docs/src/cli/fast-math.md`. Cache key in `object_cache.rs` gains a `fmath` field so toggling the flag invalidates stale `.o` bytes.

Bug fixes since v0.5.583

  • v0.5.584-585: rest-parameter bundling for class methods (#484)
  • v0.5.585: fast-math opt-in (#139)

Don't miss a new perry release

NewReleases is sending notifications on new releases.