fix(runtime): preserve Error heritage across class factory evaluations - #9946
fix(runtime): preserve Error heritage across class factory evaluations#9946proggeramlug wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe runtime now checks recorded prototype chains when evaluating ChangesError identity resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Dependency-generated Error subclasses now retain global Error identity after repeated dynamic class evaluation, restoring framework error handling without an identified remaining merge risk. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
jdalton
left a comment
There was a problem hiding this comment.
Review of bb077b0a43a0936ff7dc893bf252bf5bc32447b9 (2026-09-07).
The per-evaluation prototype check in js_instanceof addresses the shared-class-ID overwrite directly. Please extend the regression to cover the false result as well: create an Object-backed instance from the same factory, evaluate the Error-backed factory, and assert the earlier plain instance is still not an Error. Also test an Error-backed instance created before the subsequent Object evaluation. The new early return treats Some(false) as authoritative, so a positive-only true true true assertion leaves half of that contract uncovered. This is a coverage request; I did not establish a defect in the implementation.
Validation scope: source/diff inspection; I have not run this PR's build or test suite locally.
|
Landed on |
A
compilePackagesconstructor factory could evaluate one nested class template with different parents. Later evaluations overwrote the shared class-id parent registry, so an earlier Error-backed instance failedinstanceof Erroreven though its recorded prototype chain still containedError. Zod 4's$constructorfollows this pattern, causing Hono to treat validation errors like thrown strings.This change makes an object's recorded class-evaluation prototype authoritative for
instanceof Error, then falls back to the existing shared class-id metadata for ordinary instances. The regression fixture compiles a source package that evaluates the same dynamic class with Object, Error, then Object parents.Fixes #9940.
Validation:
issue_9940_compile_package_error_identityregression: passes; baseline output wasfalse true true, fixed output istrue true truezod instanceof ZodError,zod instanceof Error, app subclass, and plain Error all report trueperry-runtime: 3,259 passed, 4 ignored; doc tests passedscripts/run_lint_gates.sh: all 66 gates passed, 2 CI-only commands skippedSummary by CodeRabbit
instanceof Errorbehavior for error subclasses created through compiled packages.Erroridentity, including after repeated class evaluations.