Skip to content

Commit

Permalink
[patch] change Symbol.iterator fallback from callable check to nullis…
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 18, 2023
1 parent 9fa13a0 commit ec3e255
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions aos/GetIteratorFlattenable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ var $TypeError = GetIntrinsic('%TypeError%');
var AdvanceStringIndex = require('es-abstract/2022/AdvanceStringIndex');
var Call = require('es-abstract/2022/Call');
var GetIteratorDirect = require('./GetIteratorDirect');
var GetV = require('es-abstract/2022/GetV');
var GetMethod = require('es-abstract/2022/GetMethod');
var IsArray = require('es-abstract/2022/IsArray');
var IsCallable = require('es-abstract/2022/IsCallable');
var Type = require('es-abstract/2022/Type');

var getIteratorMethod = require('es-abstract/helpers/getIteratorMethod');
Expand All @@ -21,18 +20,18 @@ module.exports = function GetIteratorFlattenable(obj) {

var method = void undefined; // step 2

// method = Get(obj, Symbol.iterator); // step 5.a
// method = GetMethod(obj, Symbol.iterator); // step 5.a
method = getIteratorMethod(
{
AdvanceStringIndex: AdvanceStringIndex,
GetMethod: GetV,
GetMethod: GetMethod,
IsArray: IsArray
},
obj
);

var iterator;
if (!IsCallable(method)) { // step 3
if (typeof method === 'undefined') { // step 3
iterator = obj; // step 3.a
} else { // step 4
iterator = Call(method, obj); // step 4.a
Expand Down
2 changes: 1 addition & 1 deletion test/Iterator.prototype.flatMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = {
return n.next();
}
};
ret[Symbol.iterator] = 0;
ret[Symbol.iterator] = null;
return ret;
}), [0, 1, 2], st, 'test262: test/built-ins/Iterator/prototype/flatMap/iterable-to-iterator-fallback');

Expand Down

0 comments on commit ec3e255

Please sign in to comment.