fix(hir): restore function constructors after block class shadowing - #11221
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughConstructor lowering captures an eligible function binding before lowering arguments and uses it for dynamic construction. New HIR and native regression coverage exercises block-scoped class shadows and related constructor bindings. ChangesFunction constructor shadow resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to No actionable constructor-resolution issue remains; the change is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 4 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 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 |
2d02128 to
899e99b
Compare
Fixes #11160.
After
{ const C = class { k = 2 }; }shadows a module-levelfunction C(),new C()kept constructing the expired class. Confirmed on pristine main: the original reproducer prints2, while Node 26.5.1 prints1. Ordinary reads and calls already resolve the outer function correctly.Snapshot the visible function constructor before argument lowering and dispatch it before consulting the unscoped class/alias metadata. Preserve the existing precedence for nearer locals, class declarations, class self-bindings, and explicit global constructors.
Validation:
Checked GitHub for an existing PR and audited local worktrees/session history plus repository state and sessions on
root@perrymaster.skelpo.netbefore starting. No competing work found. No version bump.CI note: the public benchmark evidence freshness gate already fails on unchanged main inputs (#10030).
Summary by CodeRabbit
new C()uses the visible outer function after a block-scoped class binding ends, while preserving nearer local and class self-bindings.