Skip to content

fix(hir): #871 part 2 — Uint8Array.of(...) > 16 args (uuid sha1.js)#913

Merged
proggeramlug merged 1 commit into
mainfrom
fix-871-part2-uint8array-of-20-args
May 17, 2026
Merged

fix(hir): #871 part 2 — Uint8Array.of(...) > 16 args (uuid sha1.js)#913
proggeramlug merged 1 commit into
mainfrom
fix-871-part2-uint8array-of-20-args

Conversation

@proggeramlug
Copy link
Copy Markdown
Contributor

Summary

  • Adds an "of" arm to the Uint8Array static-method lowering at crates/perry-hir/src/lower/expr_call.rs:1108-1120 that rewrites Uint8Array.of(a, b, c, ...)Expr::Uint8ArrayFrom(Expr::Array(args)), mirroring the existing Array.of arm at :1618-1621.
  • Closes the Call callee shape not supported (PropertyGet) with 20 args codegen bail at crates/perry-codegen/src/lower_call.rs::~3226 that uuid's sha1.js hit when returning its 160-bit SHA-1 output via Uint8Array.of(H[0]>>24, ..., H[4]). Also closes a silent value is not a function runtime TypeError that was present for Uint8Array.of calls with <= 16 args (the PropertyGet receiver lowers to 0.0, so the closure-call fallback threw at runtime even when it did not bail at codegen).
  • Pure HIR change — no codegen / runtime / new symbols. The closure-call arity ceiling (args.len() <= 16) and the js_closure_call0..16 family stay untouched; Uint8Array.of(...) now produces the same HIR shape that Uint8Array.from([...args]) has produced since the original Uint8ArrayFrom lowering landed.

Part 1 of #871 (the HIR named-default-function gap) was closed by #890. This PR closes part 2 (the codegen gap that the v0.5.925 changelog entry called out as the remaining v4 runtime blocker).

Test plan

  • New regression test test-files/test_issue_871_propertyget_callee_20_args.ts (Uint8Array.of(1, 2, ..., 20) → expects len: 20 first: 1 last: 20). Byte-identical to node --experimental-strip-types.
  • Synthetic 3-arg test (Uint8Array.of(1, 2, 3)) — pre-fix runtime-TypeError-d; post-fix works.
  • uuid full-package compile (/tmp/perry-uuid reproducer from the v0.5.925 entry): node_modules/uuid/dist/sha1.js now emits a full object file (no failed-modules stub fallback).
  • Uint8Array.from([1,2,3]) + Array.of(1,2,3) still work (no regression in adjacent static-method arms).
  • cargo fmt clean.
  • cargo build --release -p perry clean.

Closes #871.

Add an `"of"` arm to the `Uint8Array` static-method lowering at
`crates/perry-hir/src/lower/expr_call.rs:1108-1120` that rewrites
`Uint8Array.of(a, b, c, ...)` to `Expr::Uint8ArrayFrom(Expr::Array(args))`,
exactly mirroring the existing `Array.of` arm at :1618-1621.

Pre-fix the codegen bailed with `Call callee shape not supported
(PropertyGet) with 20 args` for uuid's `sha1.js`
(`Uint8Array.of(H[0]>>24, ..., H[4])` returning the 160-bit SHA-1 output)
because the static dispatch tower didn't recognize `Uint8Array.of`, the
generic method-dispatch path at `lower_call.rs:~3055` skipped the
`Expr::GlobalGet(_)` receiver, and the closure-call fallback at `~3167`
was gated by `args.len() <= 16` (no `js_closure_call17..20` exists). Even
for ≤ 16 args the closure-call fallback threw `value is not a function`
at runtime because the `Uint8Array.of` PropertyGet lowers to `0.0`. Both
the > 16 codegen bail and the silent ≤ 16 TypeError-at-runtime are closed
by the HIR rewrite — no codegen or runtime changes needed.

Adds regression test
`test-files/test_issue_871_propertyget_callee_20_args.ts`
(`Uint8Array.of(1..20)` → `len: 20 first: 1 last: 20`, byte-identical to
`node --experimental-strip-types`).

Closes #871 (part 1 was closed by #890; part 2 closes here).
@proggeramlug proggeramlug merged commit 3a6c90f into main May 17, 2026
7 of 9 checks passed
@proggeramlug proggeramlug deleted the fix-871-part2-uint8array-of-20-args branch May 17, 2026 13:45
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.

Tracking: uuid not e2e-functional after #837 link fix — HIR lower + sha1.js codegen gaps

1 participant