Reviewers: Jarin,
Description:
[es6] Fix invalid ToObject in String/Array iterator next.
The spec says that the "this value" has to be an Object.
[email protected]
Please review this at https://codereview.chromium.org/1325023003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+6, -4 lines):
M src/array-iterator.js
M src/string-iterator.js
Index: src/array-iterator.js
diff --git a/src/array-iterator.js b/src/array-iterator.js
index
e59bfd782ab0f24f5c76b3d1cd108fddfed1a6f6..762714e0e377233b65412b54dc02002735e0732a
100644
--- a/src/array-iterator.js
+++ b/src/array-iterator.js
@@ -76,9 +76,10 @@ function ArrayIteratorIterator() {
// 15.4.5.2.2 ArrayIterator.prototype.next( )
function ArrayIteratorNext() {
- var iterator = TO_OBJECT(this);
+ var iterator = this;
- if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
+ if (!IS_SPEC_OBJECT(iterator) ||
+ !HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
'Array Iterator.prototype.next', this);
}
Index: src/string-iterator.js
diff --git a/src/string-iterator.js b/src/string-iterator.js
index
c55d967d78d4bcc08d755ce86b23672de1e2d5d5..42ddb2391f7470c437df49e6caf577272d8b70b3
100644
--- a/src/string-iterator.js
+++ b/src/string-iterator.js
@@ -41,9 +41,10 @@ function CreateStringIterator(string) {
// 21.1.5.2.1 %StringIteratorPrototype%.next( )
function StringIteratorNext() {
- var iterator = TO_OBJECT(this);
+ var iterator = this;
- if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
+ if (!IS_SPEC_OBJECT(iterator) ||
+ !HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
'String Iterator.prototype.next');
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.