From 9427d3255b2eba784a6a61ea998b566ff7d07c4b Mon Sep 17 00:00:00 2001 From: bmeurer Date: Tue, 1 Sep 2015 23:58:52 -0700 Subject: [PATCH] [es6] Fix invalid ToObject in String/Array iterator next. The spec says that the "this value" has to be an Object. R=jarin@chromium.org Review URL: https://codereview.chromium.org/1325023003 Cr-Commit-Position: refs/heads/master@{#30533} --- src/array-iterator.js | 5 +++-- src/string-iterator.js | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/array-iterator.js b/src/array-iterator.js index e59bfd782..762714e0e 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); } diff --git a/src/string-iterator.js b/src/string-iterator.js index c55d967d7..42ddb2391 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'); } -- 2.34.1