ReviewOS

zig-utils/zig-js

Error: use prototype identity for instanceof across realms

#822
Closed chris opened this 9 days ago ·
9 days ago

Parent #465; discovered while validating #821.

OrdinaryHasInstance currently falls back to matching errorName (or any engine error for Error) after the actual prototype-chain walk fails. This is a semantic workaround: a foreign-realm TypeError is reported as an instance of the local TypeError and local Error even though its constructor/prototype correctly belong to the foreign realm. The #821 cross-realm test exposed it; the ordinary call guard itself produced the correct foreign constructor.

Reproduced on pushed 4f7718d and the class-call candidate: the native witness reports foreignCtor=true, localCtor=false, foreignInstance=true, localInstance=true. The last result must be false. Reparented errors similarly must follow their actual prototype chain, not a hidden name tag.

Acceptance: remove the name-based fallback; preserve genuine Error subclass/prototype membership, foreign-realm separation, bound constructors, custom Symbol.hasInstance and abrupt prototype lookup; include regression and integration evidence. Do not weaken the #821 cross-realm assertion or replace this with another name/tag heuristic. Any exposed error-construction/prototype defect must be diagnosed independently, not masked by instanceof.

9 days ago

The candidate removes the name/tag fallback after OrdinaryHasInstance prototype traversal. Two focused Debug and unsuppressed ReleaseSafe+TSan tests pass for foreign/local Error identity, detached/reparented errors, genuine prototype-based objects, bound constructors, custom Symbol.hasInstance and abrupt Proxy prototype lookup. The seven #821 class-call tests now pass in both Debug and TSan, including the unchanged negative local-instance assertion for a foreign class-call TypeError.

The exact baseline error/instanceof census is 302/302 positive forced-tier pairs and 302/302 default cases across seven scopes. The candidate census is rebuilding. #823 separately records the now-visible mutable intrinsic-prototype lookup defect; no instanceof fallback is being restored to conceal it. No commit or full-integration completion is claimed yet.

9 days ago

Pushed fix(error): use prototype identity for instanceof (#822). Removed only the name-based fallback after the actual prototype walk. Two dedicated tests pass Debug and unsuppressed ReleaseSafe+TSan; the realm filter passes 41/41. Measured with the adjacent #821 change: seven Error/instanceof corpus scopes remain 302/302 default and 302/302 positive forced pairs, zero flips/regressions. Full combined Debug integration is running, CI not claimed green. Cross-realm constructor identity, detached/reparented errors, bound constructors, custom hooks and abrupt proxy lookup are covered. #823 separately tracks construction through mutable public bindings; no heuristic restored.

9 days ago

Combined local integration with #821 is complete on pushed e24c4fa: native four-shard Debug run, 2156 passed, one platform skip, zero failures/leaks, 2157 linked tests, 779.3s. Current CI 33211154123 remains pending. #823 is a subsequent uncommitted change and was not part of this full-suite binary.

9 days ago

Closing with terminal combined-main integration evidence: CI 33211154123 at e24c4fa completed successfully: 53 successful checks, one skipped nightly-only check, zero failed/cancelled checks. The implementation fix(error): use prototype identity for instanceof (#822) is in that revision. This completes the pending integration condition alongside the scoped local/conformance evidence recorded above. Separately discovered Error-intrinsic, Array-realm, prototype-type and restriction-path defects remain open in #823, #824, #825 and #826; this closure does not claim those are fixed.

Sign in to comment on this issue.