Parent: #140 Tracked by: #134, #163, #164
Implement the two pinned SystemError__* error-construction exports as one coherent boundary. The declarations are byte-identical in the pinned Home SystemError.zig (revision 7ed99c02) and the Bun core inventory; the pinned Bun C++ bridge in bindings.cpp builds an ordinary Error with DontDelete system fields, and an ERR_SYSTEM_ERROR info-object shape used by node:os.
Acceptance
- Pin the exact 160-byte extern
SystemErrorlayout:errno: c_int, six 24-byteBunStringfields in declaration order (code,message,path,syscall,hostname,dest), andfd: c_intwith theminInt(c_int)no-descriptor sentinel. - Implement
SystemError__toErrorInstance: ordinaryErrorwith the exact message, optionalcode/path/dest/syscall/hostnamestring fields only when their tag is non-empty,fdonly when non-negative, and unconditionalerrno, all withDontDelete(writable, enumerable, non-configurable) attributes; conversion failures on optional fields are cleared and skipped exactly like the pinnedscope.clearException()paths. - Implement
SystemError__toErrorInstanceWithInfoObject:ErrornamedSystemErrorwith non-enumerablecode = "ERR_SYSTEM_ERROR", message"A system error occurred: {syscall} returned {code} ({message})", a plaininfoobject carryingcode/message/syscall/errno, andDontDeleteinfo/syscall/errnoon the error itself. - Cover empty/minimal and fully populated structs, lone
errno, negative/zero/positivefd, Latin-1/UTF-16 BunString fields, sibling realms, pending-exception preservation, and descriptor attribute checks in the generated compile-link-runtime fixture. - Mark both exports implemented in the Home and Bun inventories with zero unclassified entries, and update the README/private-ABI counts and evidence.
Design constraint
These bridges construct plain data properties only; they must not consult mutable userland prototypes, run user code, or replace an already-pending VM exception.
Evidence
Completed on main in runtime commit 8874cb1e with README/private-ABI evidence in 26003992.
- The pinned layout is compile-time locked (
160bytes, exact field offsets) beside the existing BunString/StringBuilder assertions. SystemError__toErrorInstanceinstalls fields in the pinned order (code,path,dest,fd,syscall,hostname,errno), materializes an own emptymessageexactly like JSC, and skips optional fields whose conversion fails;fdappears only when non-negative.SystemError__toErrorInstanceWithInfoObjectconverts each BunString once and shares the exact value between the error and its plaininfoobject; empty tags become installed empty strings, matching the unconditional pinnedputDirectcalls.- Focused fixture coverage: fully populated and minimal structs, lone
errno,fdboundaries (minInt/0/positive), Latin-1 and UTF-16 (astral + lone-surrogate) fields, key insertion order, every descriptor attribute, null-struct rejection without a replacement exception, pending-exception preservation for both bridges, and sibling-realm prototype/field identity. - Generated Home consumer: 280/280 symbols linked; runtime matrix passed.
- Home inventory: 278/431 implemented, 153 pending, zero unclassified.
- Bun core inventory: 270/421 implemented, 151 pending, zero unclassified.
- Public/private export audit: 117 public functions complete, 286 classified private profile exports.
- Full unit suite from a clean tree at
894d22a5plus this slice (compiler0.17.0-dev.1413+addc3c3b8): 1094 passed, 0 skipped, 0 leaked, with one pre-existing failure ingc.test.Object fits the 128-byte GC slab and cold sidecar fits 256 bytesfrom the in-flight GC/WASM work on main at the time (src/gc.zig/src/value.zigare untouched by this slice). - The committed 1,540-sample benchmark matrix remains current because these construction-only bridges are outside its workloads.