Skip to content

Give every Proxy invariant violation a descriptive TypeError message#2677

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:proxy-invariant-messages
Jul 13, 2026
Merged

Give every Proxy invariant violation a descriptive TypeError message#2677
lahma merged 1 commit into
sebastienros:mainfrom
lahma:proxy-invariant-messages

Conversation

@lahma

@lahma lahma commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Final cleanliness piece of the Proxy series (#2674/#2675/#2676). 22 invariant-check sites threw bare TypeErrors with no hint of which trap misbehaved or why:

Object.keys(new Proxy(Object.freeze({ a: 1 }), { ownKeys: () => ['b'] }))
// before: TypeError (no message)
// after:  TypeError: 'ownKeys' on proxy: trap result did not include non-configurable property 'a' of the proxy target

Every site now carries a V8-styled message naming the trap, the property, and the violated invariant — matching the tone of the handful of sites that already had rich messages (get/set/deleteProperty). The non-callable-trap error also drops the awkward [object Object] returned for property 'get' of object ... phrasing for V8's 'get' trap of proxy handler is not a function.

Two merged conditions (getOwnPropertyDescriptor undefined-result, defineProperty missing-property) are split so each branch names its own violation — evaluation order unchanged. All messages interpolate only on the throw path, so hot paths are untouched (perf-flat by construction).

Verification: full Jint.Tests, PublicInterface, test262 ~Proxy/~Reflect green (test262 never asserts messages); new exact-message assertions added to ProxyTests.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EsHuKuE4UihKZp5HYapDHE

22 invariant-check sites threw bare TypeErrors with no explanation of
which trap misbehaved or why. Each now carries a V8-styled message
naming the trap, the property and the violated invariant, matching the
tone of the handful of sites that already had rich messages. The
non-callable-trap error also drops the awkward
"[handler] returned for property..." phrasing for V8's
"'get' trap of proxy handler is not a function".

Two merged conditions (getOwnPropertyDescriptor undefined-result and
defineProperty missing-property) are split so each branch can name its
own violation; evaluation order is unchanged. All messages interpolate
only on the throw path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsHuKuE4UihKZp5HYapDHE
@lahma
lahma enabled auto-merge (squash) July 13, 2026 19:40
@lahma
lahma merged commit 2be26ad into sebastienros:main Jul 13, 2026
4 checks passed
@lahma
lahma deleted the proxy-invariant-messages branch July 13, 2026 19: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.

1 participant