Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1084)

Unified Diff: src/array-iterator.js

Issue 268363011: Array Iterator next should check for own property (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use HAS_PRIVATE Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/array-iterator.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array-iterator.js
diff --git a/src/array-iterator.js b/src/array-iterator.js
index f1e1800bfb8f1e7b217daa02c7546945bf1188b8..a96b9cb7c660b51efb59679f75a9eb7281f85e42 100644
--- a/src/array-iterator.js
+++ b/src/array-iterator.js
@@ -38,12 +38,17 @@ function CreateIteratorResultObject(value, done) {
// 15.4.5.2.2 ArrayIterator.prototype.next( )
function ArrayIteratorNext() {
var iterator = ToObject(this);
- var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol);
- if (!array) {
+
+ if (!HAS_PRIVATE(iterator, arrayIteratorObjectSymbol)) {
throw MakeTypeError('incompatible_method_receiver',
['Array Iterator.prototype.next']);
}
+ var array = GET_PRIVATE(iterator, arrayIteratorObjectSymbol);
+ if (IS_UNDEFINED(array)) {
+ return CreateIteratorResultObject(UNDEFINED, true);
+ }
+
var index = GET_PRIVATE(iterator, arrayIteratorNextIndexSymbol);
var itemKind = GET_PRIVATE(iterator, arrayIterationKindSymbol);
var length = TO_UINT32(array.length);
@@ -51,17 +56,19 @@ function ArrayIteratorNext() {
// "sparse" is never used.
if (index >= length) {
- SET_PRIVATE(iterator, arrayIteratorNextIndexSymbol, INFINITY);
+ SET_PRIVATE(iterator, arrayIteratorObjectSymbol, UNDEFINED);
return CreateIteratorResultObject(UNDEFINED, true);
}
SET_PRIVATE(iterator, arrayIteratorNextIndexSymbol, index + 1);
- if (itemKind == ITERATOR_KIND_VALUES)
+ if (itemKind == ITERATOR_KIND_VALUES) {
return CreateIteratorResultObject(array[index], false);
+ }
- if (itemKind == ITERATOR_KIND_ENTRIES)
+ if (itemKind == ITERATOR_KIND_ENTRIES) {
return CreateIteratorResultObject([index, array[index]], false);
+ }
return CreateIteratorResultObject(index, false);
}
« no previous file with comments | « no previous file | test/mjsunit/harmony/array-iterator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698