Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

fixes #163: close both iterators in flatMap #195

Merged
merged 2 commits into from
Jul 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,11 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1>
1. Else,
1. Let _innerValue_ be Completion(IteratorValue(_innerNext_)).
1. IfAbruptCloseIterator(_innerValue_, _iterated_).
1. Let _yielded_ be Completion(Yield(_innerValue_)).
1. IfAbruptCloseIterator(_yielded_, _iterated_).
1. Let _completion_ be Completion(Yield(_innerValue_)).
1. If _completion_ is an abrupt completion, then
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
1. IfAbruptCloseIterator(_backupCompletion_, _iterated_).
Comment on lines +648 to +649
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
1. IfAbruptCloseIterator(_backupCompletion_, _iterated_).
1. Let _innerCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
1. IfAbruptCloseIterator(_innerCompletion_, _iterated_).

1. Return ? IteratorClose(_completion_, _iterated_).
1. Return CreateIteratorFromClosure(_closure_, ~Iterator Helper~, %IteratorHelperPrototype%).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -903,8 +906,14 @@ <h1>AsyncIterator.prototype.flatMap ( _mapper_ )</h1>
1. Else,
1. Let _innerValue_ be Completion(IteratorValue(_innerNext_)).
1. IfAbruptCloseAsyncIterator(_innerValue_, _iterated_).
1. Let _yielded_ be Completion(Yield(_innerValue_)).
1. IfAbruptCloseAsyncIterator(_yielded_, _iterated_).
1. [id="step-async-iterator-flatmap-yield"] Let _completion_ be Completion(Yield(_innerValue_)).
1. If _completion_ is a return completion, then
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
1. IfAbruptCloseIterator(_backupCompletion_, _iterated_).
Comment on lines +911 to +912
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Let _backupCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
1. IfAbruptCloseIterator(_backupCompletion_, _iterated_).
1. Let _innerCompletion_ be Completion(IteratorClose(_innerIterator_, _completion_)).
1. IfAbruptCloseIterator(_innerCompletion_, _iterated_).

1. Return ? IteratorClose(_completion_, _iterated_).
1. Else if _completion_ is a throw completion, then
1. Assert: Awaiting _innerValue_ during the Yield on step <emu-xref href="#step-async-iterator-flatmap-yield"></emu-xref> threw.
1. Return ? IteratorClose(_completion_, _iterated_).
1. Return CreateAsyncIteratorFromClosure(_closure_, ~Async Iterator Helper~, %AsyncIteratorHelperPrototype%).
</emu-alg>
</emu-clause>
Expand Down