tc39 / proposal-joint-iteration

a TC39 proposal to synchronise the advancement of multiple iterators
https://tc39.es/proposal-joint-iteration
51 stars 2 forks source link

exceptions thrown while reading from an iterator should not close that iterator #5

Closed bakkot closed 7 months ago

bakkot commented 7 months ago

For example, Iterator.zip step 13.b puts inputIter in openIters, and then 13.d.ii closes everything in openIters (including inputIter) if the reading the value property of the iterator result object from inputIter throws.

But a throwy getter for the value property from the iterator result object from inputIter is a violation of the iterator protocol, and so should not cause inputIter to be closed.

Similarly for step 13.d.vii/viii.

inputIter should probably not get put in openIters at the start of the loop. Instead, only add it after the Let iter be Completion(GetIteratorFlattenable(value, ITERATE-STRINGS)) step in the case that this step is an abrupt completion: something like

1. If _iter_ is an abrupt completion, then
  1. Set _openIters_ to the list-concatenation of « _inputIter_ » and _openIters_.
  1. Return ? IteratorCloseAll(_openIters_, _iter_).