Skip to content

fix(expressions): iterator return/close protocol in destructuring (6 tests) #429

Description

@dowdiness

Root cause

When array destructuring exhausts the iterator early (e.g., via a rest element or because fewer elements are consumed than exist), the iterator's return() method must be called to signal early close. The engine does not call return() in all required cases.

Additional sub-cluster: when return() itself throws, the exception must propagate correctly.

Failure breakdown — language/expressions suite (2026-06-21)

All 6 unique failing tests are in assignment/dstr/:

  • array-elem-iter-rtrn-close.js — return() not called after partial consume
  • array-rest-iter-rtrn-close.js — return() not called after rest collect
  • array-elem-iter-rtrn-close-err.js — return() throws, exception not propagated
  • array-rest-iter-rtrn-close-err.js — same for rest
  • array-elem-iter-rtrn-close-null.js — return() returns null, should not throw
  • array-rest-iter-rtrn-close-null.js — same for rest

Fix direction

IteratorClose (§7.4.9) must be called in ArrayAssignmentPattern evaluation after the binding list is complete if the iterator is not already done. Verify both the normal path and the abrupt completion path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconformanceECMAScript conformancetest262Test262 conformance work

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions