Skip to content

Add ES2015 Iterator return() method foundation#2079

Closed
anivar wants to merge 1 commit intomozilla:masterfrom
anivar:es2015-iterator-return-fix
Closed

Add ES2015 Iterator return() method foundation#2079
anivar wants to merge 1 commit intomozilla:masterfrom
anivar:es2015-iterator-return-fix

Conversation

@anivar
Copy link
Copy Markdown
Contributor

@anivar anivar commented Sep 12, 2025

Summary

Implements the IteratorClose abstract operation from ES2015 spec section 7.4.6 as foundation work towards issue #1409.

Changes Added

  • ScriptRuntime.iteratorClose(): Core method implementing IteratorClose abstract operation
  • ScriptRuntime.performIteratorClose(): Helper method for iterator cleanup logic
  • IteratorCloseTest: Unit tests verifying the foundation methods
  • IteratorReturnTest: Integration tests (currently expected to fail until full integration)

Current Status

Foundation methods implemented correctly per ES2015 spec. Unit tests pass - core functionality verified. Integration incomplete - requires control flow changes.

The foundation is solid. Full implementation needs architectural discussion on #1409 for proper integration with for-of loop control flow (break/throw/return scenarios).

Test Results

  • test262 for-of status: 438/751 (58.32%) - unchanged as expected for foundational work
  • IteratorCloseTest: All pass
  • IteratorReturnTest: Expected failures until integration complete

Related to #1409

Implements the IteratorClose abstract operation from ES2015 spec section 7.4.6
as foundation for issue mozilla#1409 - ES2015 Iterator protocol return() method not called.

Added:
- ScriptRuntime.iteratorClose(): Core method implementing IteratorClose operation
- ScriptRuntime.performIteratorClose(): Helper method for actual iterator cleanup
- IteratorCloseTest: Unit tests for the foundation methods
- IteratorReturnTest: Integration tests (currently expected to fail)
- Updated test262.properties with current test baselines

The foundation methods correctly implement the ES2015 specification but are not
yet integrated into for-of loop control flow. This requires architectural changes
to properly track loop boundaries and intercept abnormal loop exits (break/throw/return).

Current test262 for-of status remains 438/751 (58.32%) as expected for foundational work.
@anivar
Copy link
Copy Markdown
Contributor Author

anivar commented Sep 13, 2025

Closing this PR for now. The Iterator return() method foundation work will be revisited after the ES2025 Iterator implementation in #2078 is complete.

The current approach in #2078 with feature flags provides a cleaner migration path, and the iterator protocol's return() method (for for-of loop cleanup) is a separate concern from the ES2025 Iterator helpers.

The CI failures also indicate this needs more work:

  • WeakRef test failures due to missing WeakRef implementation on this branch
  • IteratorReturnTest failures as expected (incomplete implementation)

Will create a fresh PR for iterator return() support once the ES2025 Iterator foundation is merged.

@anivar anivar closed this Sep 13, 2025
@anivar anivar deleted the es2015-iterator-return-fix branch September 13, 2025 18:40
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