IteratorClose in ForIn/OfBodyEvaluation
GeorgNeis opened this issue · 2 comments
The changes at the end of ForIn/OfBodyEvaluation don't make sense to me. They seem to assume that IteratorClose
returns the value returned by the iterator's return
method, which is not the case. More specifically:
- In 6.j.ii, since
status
is abrupt, so isIteratorClose(iterator, status)
. Hence the following steps will never be executed. - In 6.m.i,
IteratorClose(iterator, UpdateEmpty(result, V))
is either abrupt or a normal completion with the value produced by the body in the previous iteration. Why would we want to await on that value?
In 6.j.ii, since status is abrupt, so is IteratorClose(iterator, status). Hence the following steps will never be executed.
This is only true if status is a throw completion, not a return/break/continue completion. If it is one of those, return()s completion value is given. Do you know if it is always throw?
Why would we want to await on that value?
The idea is that if return() returns a promise, we should await on it. I think this is not correctly captured by the current spec because IteratorClose is more complicated than it appears from the outside.
Probably this is all only fixable by modifying IteratorClose.
This is only true if status is a throw completion, not a return/break/continue completion. If it is one of those, return()s completion value is given. Do you know if it is always throw?
return()s completion value is only ever returned if it is a throw-completion.