Skip to content

Commit

Permalink
fix: Replace IteratorStep with NextMethod (#44)
Browse files Browse the repository at this point in the history
Fixes #33.
Prevents an infinite loop caused by IteratorStep(iteratorRecord) not actually flagging termination when IteratorRecord is async. Instead, we will directly call iteratorStep.[[NextMethod]], like how `for await` does.

Co-authored-by: Kevin Gibbons <[email protected]>
  • Loading branch information
js-choi and bakkot authored Dec 21, 2023
1 parent 52a4684 commit 689d0d4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ <h1><ins>Array.fromAsync ( _asyncItems_ [ , _mapfn_ [ , _thisArg_ ] ] )</ins></h
1. Let _error_ be ThrowCompletion(a newly created *TypeError* object).
1. Return ? AsyncIteratorClose(_iteratorRecord_, _error_).
1. Let _Pk_ be ! ToString(𝔽(_k_)).
1. Let _next_ be ? Await(IteratorStep(_iteratorRecord_)).
1. If _next_ is *false*, then
1. Let _nextResult_ be ? Call(_iteratorRecord_.[[NextMethod]], _iteratorRecord_.[[Iterator]]).
1. Set _nextResult_ to ? Await(_nextResult_).
1. If _nextResult_ is not an Object, throw a *TypeError* exception.
1. Let _done_ be ? IteratorComplete(_nextResult_).
1. If _done_ is *true*,
1. Perform ? Set(_A_, *"length"*, 𝔽(_k_), *true*).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _A_, [[Target]]: ~empty~ }.
1. Let _nextValue_ be ? IteratorValue(_next_).
Expand Down

0 comments on commit 689d0d4

Please sign in to comment.