-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove hint from GetIteratorFlattenable #271
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,33 +129,22 @@ <h1> | |
<emu-clause id="sec-getiteratorflattenable" type="abstract operation"> | ||
<h1> | ||
GetIteratorFlattenable ( | ||
_obj_: an ECMAScript language value, | ||
_hint_: ~sync~ or ~async~, | ||
_obj_: an ECMAScript language value | ||
): either a normal completion containing an Iterator Record or a throw completion | ||
</h1> | ||
<dl class="header"> | ||
</dl> | ||
<emu-alg> | ||
1. If _obj_ is not an Object, throw a *TypeError* exception. | ||
1. Let _alreadyAsync_ be *false*. | ||
1. Let _method_ be *undefined*. | ||
1. If _hint_ is ~async~, then | ||
1. Set _method_ to ? Get(_obj_, @@asyncIterator). | ||
1. Set _alreadyAsync_ to *true*. | ||
1. If IsCallable(_method_) is *false*, then | ||
1. Set _method_ to ? Get(_obj_, @@iterator). | ||
1. Set _alreadyAsync_ to *false*. | ||
1. If IsCallable(_method_) is *false*, then | ||
1. Let _method_ be ? GetMethod(_obj_, @@iterator). | ||
1. If _method_ is *undefined*, then | ||
1. Let _iterator_ be _obj_. | ||
1. Set _alreadyAsync_ to *true*. | ||
1. Else, | ||
1. Let _iterator_ be ? Call(_method_, _obj_). | ||
1. If _iterator_ is not an Object, throw a *TypeError* exception. | ||
1. Let _nextMethod_ be ? Get(_iterator_, *"next"*). | ||
1. If IsCallable(_nextMethod_) is *false*, throw a *TypeError* exception. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line diverges from |
||
1. Let _iteratorRecord_ be the Iterator Record { [[Iterator]]: _iterator_, [[NextMethod]]: _nextMethod_, [[Done]]: *false* }. | ||
1. If _hint_ is ~async~ and _alreadyAsync_ is *false*, then | ||
1. Return CreateAsyncFromSyncIterator(_iteratorRecord_). | ||
1. Return _iteratorRecord_. | ||
</emu-alg> | ||
</emu-clause> | ||
|
@@ -203,7 +192,7 @@ <h1>Iterator.prototype</h1> | |
<h1>Iterator.from ( _O_ )</h1> | ||
<emu-alg> | ||
1. If _O_ is a String, set _O_ to ! ToObject(_O_). | ||
1. Let _iteratorRecord_ be ? GetIteratorFlattenable(_O_, ~sync~). | ||
1. Let _iteratorRecord_ be ? GetIteratorFlattenable(_O_). | ||
1. Let _hasInstance_ be ? OrdinaryHasInstance(%Iterator%, _iteratorRecord_.[[Iterator]]). | ||
1. If _hasInstance_ is *true*, then | ||
1. Return _iteratorRecord_.[[Iterator]]. | ||
|
@@ -414,7 +403,7 @@ <h1>Iterator.prototype.flatMap ( _mapper_ )</h1> | |
1. Let _value_ be ? IteratorValue(_next_). | ||
1. Let _mapped_ be Completion(Call(_mapper_, *undefined*, « _value_, 𝔽(_counter_) »)). | ||
1. IfAbruptCloseIterator(_mapped_, _iterated_). | ||
1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_, ~sync~)). | ||
1. Let _innerIterator_ be Completion(GetIteratorFlattenable(_mapped_)). | ||
1. IfAbruptCloseIterator(_innerIterator_, _iterated_). | ||
1. Let _innerAlive_ be *true*. | ||
1. Repeat, while _innerAlive_ is *true*, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change from Get/IsCallable to GetMethod/undefined is technically normative, but it more closely matches the existing
GetIterator
behaviour. Ifobj
has aSymbol.iterator
property that is non-callable, it will now throw instead of falling back to treatingobj
as an iterator.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed this to split it into a separate PR.
edit: See #272.