fix(runtime): observe class iterator prototype replacements - #9811
fix(runtime): observe class iterator prototype replacements#9811proggeramlug wants to merge 1 commit 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 (9)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughClass-based iteration now resolves the current ChangesIterator protocol mutation
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to Class iterator methods now remain symbol-only while current Symbol.iterator replacements are honored by direct calls and iteration. The targeted mutation and protocol coverage supports merge readiness with no outstanding risk. Sequence Diagram(s)sequenceDiagram
participant ForOfLoop
participant GetIterator
participant SymbolPropertyLookup
participant PrototypeOverrideResolver
participant Iterator
ForOfLoop->>GetIterator: request iterator for class instance
GetIterator->>SymbolPropertyLookup: read Symbol.iterator
SymbolPropertyLookup->>PrototypeOverrideResolver: inspect own and prototype replacements
PrototypeOverrideResolver-->>SymbolPropertyLookup: return current iterator method
SymbolPropertyLookup-->>GetIterator: return bound iterator method
GetIterator->>Iterator: invoke method once at loop entry
Iterator-->>ForOfLoop: produce iterator values
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
Landed on |
Class generator iterators exposed a synthetic string key in
Object.getOwnPropertyNames, and laterSymbol.iteratorreplacements could be bypassed by the class vtable, direct symbol calls, andfor...of new C()lowering. For example, replacingRange.prototype[Symbol.iterator]now changes spread, direct calls,Array.from, and module/function loops consistently.Keep the computed-symbol registration, whose runtime registration already installs the dispatch alias. Resolve current prototype properties before that alias, preserving subclass shadowing and accessor receivers. Data descriptors also replace old symbol accessors correctly, and presence checks do not invoke getters a second time.
Closes #9788.
Validation on macOS arm64 with the pinned Node 26.5.1:
*[Symbol.iterator]()generator method hangs in for...of (and growing RSS to OOM) #448, for-of / spread over a non-generator class [Symbol.iterator] doesn't iterate #1840, and ToPrimitive fixtures pass (6 additional cases).perry-devcompiler/runtime/stdlib build and Node-version consistency check passed.No version bump.
Summary by CodeRabbit
New Features
Symbol.iteratoracrossfor...of, spread syntax, andArray.from.undefinediterator replacements now correctly shadow existing methods.Bug Fixes
Tests