Define prototype.constructor on native Error hierarchy#565
Conversation
Error.prototype.constructor (and the same slot on every NativeError
subclass) was never written during realm initialisation, so
`new TypeError("x").constructor` resolved to `undefined` instead of
`TypeError`. This broke any code that reads `error.constructor.name`
— including the stock test262 `assert.throws` harness.
Add the nine missing DefineProperty calls (Error, TypeError,
RangeError, ReferenceError, SyntaxError, URIError, AggregateError,
SuppressedError, DOMException) right after the existing
Constructor.prototype assignments, matching the descriptor flags
({writable, configurable}) used by every other built-in.
Closes #519
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughNative error prototypes (Error, TypeError, RangeError, etc.) now define a ChangesError Prototype Constructor Property
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labelsspec compliance, bug, documentation 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/built-ins/Error/error-prototype-constructor.js`:
- Around line 30-48: The tests currently assert constructor descriptors for
native errors but omit SuppressedError and DOMException; update the test
"NativeError.prototype.constructor descriptors..." to include SuppressedError
and DOMException by adding them to the types array (i.e., const types =
[TypeError, RangeError, ReferenceError, SyntaxError, URIError, AggregateError,
SuppressedError, DOMException]) so their prototype "constructor" property is
also checked for {writable: true, configurable: true, enumerable: false} using
the existing Object.getOwnPropertyDescriptor/assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3a70bc1d-83aa-45cd-a7de-63f5f4490d09
📒 Files selected for processing (3)
docs/built-ins.mdsource/units/Goccia.Builtins.Globals.pastests/built-ins/Error/error-prototype-constructor.js
…nstructor Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Suite TimingTest Runner (interpreted: 8,869 passed; bytecode: 8,869 passed)
MemoryGC rows aggregate the main thread plus all worker thread-local GCs. Test runner worker shutdown frees thread-local heaps in bulk; that shutdown reclamation is not counted as GC collections or collected objects.
Benchmarks (interpreted: 407; bytecode: 407)
MemoryGC rows aggregate the main thread plus all worker thread-local GCs. Benchmark runner performs explicit between-file collections, so collection and collected-object counts can be much higher than the test runner.
Measured on ubuntu-latest x64. |
Benchmark Results407 benchmarks Interpreted: 🟢 349 improved · 🔴 16 regressed · 42 unchanged · avg +8.2% arraybuffer.js — Interp: 🟢 10, 🔴 1, 3 unch. · avg +8.2% · Bytecode: 🔴 12, 2 unch. · avg -9.1%
arrays.js — Interp: 🟢 18, 1 unch. · avg +9.9% · Bytecode: 🔴 17, 2 unch. · avg -9.6%
async-await.js — Interp: 🟢 5, 1 unch. · avg +10.3% · Bytecode: 🔴 4, 2 unch. · avg -10.0%
async-generators.js — Interp: 🟢 1, 1 unch. · avg +11.7% · Bytecode: 🔴 1, 1 unch. · avg -12.2%
base64.js — Interp: 🟢 10 · avg +12.1% · Bytecode: 🔴 10 · avg -11.8%
classes.js — Interp: 🟢 27, 4 unch. · avg +7.8% · Bytecode: 🟢 1, 🔴 18, 12 unch. · avg -3.9%
closures.js — Interp: 🟢 10, 1 unch. · avg +11.6% · Bytecode: 🔴 11 · avg -10.5%
collections.js — Interp: 🟢 12 · avg +9.2% · Bytecode: 🔴 12 · avg -10.1%
csv.js — Interp: 🟢 13 · avg +9.9% · Bytecode: 🔴 13 · avg -9.4%
destructuring.js — Interp: 🟢 21, 1 unch. · avg +10.0% · Bytecode: 🔴 20, 2 unch. · avg -7.1%
fibonacci.js — Interp: 🟢 8 · avg +10.8% · Bytecode: 🔴 8 · avg -11.7%
float16array.js — Interp: 🟢 25, 🔴 4, 3 unch. · avg +4.8% · Bytecode: 🟢 4, 🔴 27, 1 unch. · avg -7.8%
for-of.js — Interp: 🟢 6, 1 unch. · avg +5.2% · Bytecode: 🔴 6, 1 unch. · avg -6.4%
generators.js — Interp: 🟢 3, 1 unch. · avg +9.2% · Bytecode: 🔴 4 · avg -6.4%
iterators.js — Interp: 🟢 36, 6 unch. · avg +6.8% · Bytecode: 🔴 27, 15 unch. · avg -4.6%
json.js — Interp: 🟢 20 · avg +13.2% · Bytecode: 🔴 20 · avg -10.4%
jsx.jsx — Interp: 🟢 18, 3 unch. · avg +7.6% · Bytecode: 🟢 1, 🔴 7, 13 unch. · avg -2.2%
modules.js — Interp: 🟢 9 · avg +8.9% · Bytecode: 🔴 9 · avg -16.4%
numbers.js — Interp: 🟢 11 · avg +12.6% · Bytecode: 🔴 11 · avg -9.7%
objects.js — Interp: 🟢 3, 🔴 1, 3 unch. · avg +1.2% · Bytecode: 🔴 4, 3 unch. · avg -3.1%
promises.js — Interp: 🟢 11, 1 unch. · avg +9.8% · Bytecode: 🔴 12 · avg -9.3%
regexp.js — Interp: 🟢 11 · avg +10.4% · Bytecode: 🔴 10, 1 unch. · avg -7.1%
strings.js — Interp: 🟢 15, 4 unch. · avg +8.2% · Bytecode: 🔴 18, 1 unch. · avg -7.8%
tsv.js — Interp: 🟢 8, 1 unch. · avg +9.6% · Bytecode: 🔴 9 · avg -10.4%
typed-arrays.js — Interp: 🟢 19, 🔴 1, 2 unch. · avg +9.3% · Bytecode: 🟢 6, 🔴 10, 6 unch. · avg +5.2%
uint8array-encoding.js — Interp: 🟢 9, 🔴 5, 4 unch. · avg +1.4% · Bytecode: 🟢 1, 🔴 15, 2 unch. · avg -10.9%
weak-collections.js — Interp: 🟢 10, 🔴 4, 1 unch. · avg +3.3% · Bytecode: 🔴 13, 2 unch. · avg -7.8%
Deterministic profile diffDeterministic profile diff: no significant changes. Measured on ubuntu-latest x64. Benchmark ranges compare cached main-branch min/max ops/sec with the PR run; overlapping ranges are treated as unchanged noise. Percentage deltas are secondary context. |
test262 Conformance
Areas closest to 100%
Per-test deltas (+403 / -2)Newly failing (2):
Newly passing (403):
Steady-state failures are non-blocking; regressions vs the cached main baseline (lower total pass count, or any PASS → non-PASS transition) fail the conformance gate. Measured on ubuntu-latest x64, bytecode mode. Areas grouped by the first two test262 path components; minimum 25 attempted tests, areas already at 100% excluded. Δ vs main compares against the most recent cached |
Summary
prototype.constructorproperty to all nine native error prototypes (Error, TypeError, RangeError, ReferenceError, SyntaxError, URIError, AggregateError, SuppressedError, DOMException) during realm initializationcaught.constructor.nameusage viatest.eachconstructorproperty in the error section ofbuilt-ins.mdCloses #519
Testing
Details:
tests/built-ins/Error/error-prototype-constructor.js— 12 tests, 42 assertions, all passtests/built-ins/Error/suite — 136/136 pass (no regressions)🤖 Generated with Claude Code