Files
scriptc/tests/corpus/7602-error-stack-limit-value.js
T
Malte UblandClaude Opus 5.5 7f7e11a1a7 Read and write Error.stackTraceLimit through the Error constructor value
zod 4 saves and restores the limit through an alias,
`const E = "captureStackTrace" in Error ? Error : null`. The interned
Error constructor value now answers `stackTraceLimit` from the same limit
the static member and stack capture use, and numeric writes set it, so
`E.stackTraceLimit` reads 10 instead of undefined and `E.stackTraceLimit = 0`
reaches `Error.stackTraceLimit`.

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

19 lines
744 B
JavaScript

// Error.stackTraceLimit through the Error constructor held as a value
// (zod 4's `const E = "captureStackTrace" in Error ? Error : null`): reads
// and writes reach the same limit as the static member.
const E = "captureStackTrace" in Error ? Error : null;
console.log(typeof E, E === Error, E.stackTraceLimit, Error.stackTraceLimit);
const saved = E.stackTraceLimit;
E.stackTraceLimit = 0;
console.log(Error.stackTraceLimit, E.stackTraceLimit, typeof saved === "number");
console.log(new Error("no frames").stack);
try {
E.stackTraceLimit = 3;
console.log(Error.stackTraceLimit);
} finally {
E.stackTraceLimit = saved;
}
console.log(E.stackTraceLimit, Error.stackTraceLimit);
Error.stackTraceLimit = 4;
console.log(E.stackTraceLimit);