Files
scriptc/tests/corpus/6237-error-subclass-delete-stack/main.js
T
Malte UblandClaude Opus 5.5 c600e8daa5 Delete V8's own stack on Error subclasses with a stack accessor
quickjs-wasi's JSException constructor runs `delete this.stack` so V8's
own stack property stops shadowing the class's stack accessor; scriptc
fenced the delete, so every guest exception reaching the host threw the
fence error. Compiled errors keep the trace internally and class dispatch
already reads the accessor, so the delete now evaluates its receiver and
nothing else, for Error subclasses whose chain declares a stack getter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 15:15:05 -07:00

13 lines
401 B
JavaScript

// Deleting `stack` on an Error subclass that declares a stack accessor
// lets reads reach the accessor (the package's guest exceptions).
import { GuestError } from "guest-error";
try {
throw new GuestError(7);
} catch (e) {
console.log(e instanceof GuestError, e instanceof Error, e.handle, e.message);
console.log(e.stack);
e.stack = "rewritten";
console.log(e.stack, Object.keys(e));
}