archives

« Bugzilla Issues Index

#3244 — 13.6.4.9 ForIn/OfBodyEvaluation: Skip IteratorClose in for-in statement loop?


13.6.4.9 Runtime Semantics: ForIn/OfBodyEvaluation

for-in loop iteration currently also calls IteratorClose, is this intentional?


Yes. Is there any reason it shouldn't? The [[Enumerate]] internal method returns an iterator that could have a 'close' method.


I didn't see any mentions of for-in loops in discussions about the 'return' method proposal on es-discuss or in the tc39-notes, so I figured it makes sense to ask about this. But maybe I've just overlooked something.

Resolving as 'Invalid'.


It's really more about the fact that an iterator is used, rather than the syntax of the loop.

The basic idea, is that if an iterator-based loop exits before exhausting the iterator it should invoke 'return' (if it exists) on the iterator to allow the iterator to do any cleanup it needs.