Skip to content

feat: improve iterator protocol conformance for Test262#473

Merged
telecos merged 4 commits intomainfrom
feat/iterator-protocol
Mar 14, 2026
Merged

feat: improve iterator protocol conformance for Test262#473
telecos merged 4 commits intomainfrom
feat/iterator-protocol

Conversation

@telecos
Copy link
Owner

@telecos telecos commented Mar 14, 2026

Summary

Improve Test262 conformance for the iterator protocol by fixing several spec violations in the bytecode dispatch handlers in dispatch.rs.

Changes

A. for...of / GetIterator (7.4.1):

  • Validate that @@iterator() returns an object (TypeError if not)
  • Support call-wrapped callable objects as iterator factories

B. IteratorNext (7.4.3):

  • Throw TypeError when .next() returns a non-object result
  • Support call-wrapped next methods

C. IteratorClose (7.4.6):

  • Validate .return() result is an object (TypeError if not)
  • Propagate errors from .return() instead of silently swallowing them
  • Close generators by marking them as Completed
  • Support call-wrapped return methods

D. CreateArrayFromIterable:

  • Check @@iterator before falling back to direct .next()
  • Throw TypeError for non-object .next() results
  • Throw TypeError for null/undefined inputs
  • Extract shared collect_from_plain_object_iterator() helper

E. Spread elements:

  • Add String, NativeIterator, Generator spread support

F. for...in enumeration:

  • Enumerate string character indices

@telecos telecos merged commit b97e002 into main Mar 14, 2026
17 of 19 checks passed
@telecos telecos deleted the feat/iterator-protocol branch March 14, 2026 23:50
@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 4.67836% with 163 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/stator_core/src/interpreter/dispatch.rs 4.67% 163 Missing ⚠️

📢 Thoughts on this report? Let us know!

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