Skip to content

Commit

Permalink
[Fix] ES2024+: Iterator Records can now have non-functions in `[[Ne…
Browse files Browse the repository at this point in the history
…xtMethod]]`
  • Loading branch information
ljharb committed Nov 12, 2024
1 parent bfc3785 commit c7d7521
Show file tree
Hide file tree
Showing 26 changed files with 30 additions and 30 deletions.
6 changes: 0 additions & 6 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,6 @@
/2024/ArraySetLength.js spackled linguist-generated=true
/2024/ArraySpeciesCreate.js spackled linguist-generated=true
/2024/AsyncFromSyncIteratorContinuation.js spackled linguist-generated=true
/2024/AsyncIteratorClose.js spackled linguist-generated=true
/2024/BigInt/add.js spackled linguist-generated=true
/2024/BigInt/bitwiseAND.js spackled linguist-generated=true
/2024/BigInt/bitwiseNOT.js spackled linguist-generated=true
Expand Down Expand Up @@ -1418,7 +1417,6 @@
/2024/CompletePropertyDescriptor.js spackled linguist-generated=true
/2024/CompletionRecord.js spackled linguist-generated=true
/2024/CopyDataProperties.js spackled linguist-generated=true
/2024/CreateAsyncFromSyncIterator.js spackled linguist-generated=true
/2024/CreateDataProperty.js spackled linguist-generated=true
/2024/CreateDataPropertyOrThrow.js spackled linguist-generated=true
/2024/CreateHTML.js spackled linguist-generated=true
Expand Down Expand Up @@ -1477,11 +1475,7 @@
/2024/IsStrictlyEqual.js spackled linguist-generated=true
/2024/IsStringWellFormedUnicode.js spackled linguist-generated=true
/2024/IsWordChar.js spackled linguist-generated=true
/2024/IteratorClose.js spackled linguist-generated=true
/2024/IteratorComplete.js spackled linguist-generated=true
/2024/IteratorNext.js spackled linguist-generated=true
/2024/IteratorStep.js spackled linguist-generated=true
/2024/IteratorToList.js spackled linguist-generated=true
/2024/IteratorValue.js spackled linguist-generated=true
/2024/KeyForSymbol.js spackled linguist-generated=true
/2024/LengthOfArrayLike.js spackled linguist-generated=true
Expand Down
2 changes: 1 addition & 1 deletion 2018/AsyncIteratorClose.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var CompletionRecord = require('./CompletionRecord');
var GetMethod = require('./GetMethod');
var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

var callBound = require('call-bind/callBound');

Expand Down
2 changes: 1 addition & 1 deletion 2018/CreateAsyncFromSyncIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var ObjectCreate = require('./ObjectCreate');
var PromiseResolve = require('./PromiseResolve');
var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

var SLOT = require('internal-slot');

Expand Down
2 changes: 1 addition & 1 deletion 2019/AsyncIteratorClose.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 2019/CreateAsyncFromSyncIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var IteratorNext = require('./IteratorNext');
var ObjectCreate = require('./ObjectCreate');
var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

var SLOT = require('internal-slot');

Expand Down
2 changes: 1 addition & 1 deletion 2020/AsyncIteratorClose.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 2020/CreateAsyncFromSyncIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var IteratorNext = require('./IteratorNext');
var OrdinaryObjectCreate = require('./OrdinaryObjectCreate');
var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

var SLOT = require('internal-slot');

Expand Down
2 changes: 1 addition & 1 deletion 2021/AsyncIteratorClose.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var CompletionRecord = require('./CompletionRecord');
var GetMethod = require('./GetMethod');
var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

var callBound = require('call-bind/callBound');

Expand Down
2 changes: 1 addition & 1 deletion 2021/CreateAsyncFromSyncIterator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 2022/AsyncIteratorClose.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 2022/CreateAsyncFromSyncIterator.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 2023/AsyncIteratorClose.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 2023/CreateAsyncFromSyncIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var Type = require('./Type');

var SLOT = require('internal-slot');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorPrototype%', true) || {
next: function next(value) {
Expand Down
2 changes: 1 addition & 1 deletion 2023/IteratorClose.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var GetMethod = require('./GetMethod');
var IsCallable = require('./IsCallable');
var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

// https://262.ecma-international.org/14.0/#sec-iteratorclose

Expand Down
2 changes: 1 addition & 1 deletion 2023/IteratorNext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var $TypeError = require('es-errors/type');
var Call = require('./Call');
var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

// https://262.ecma-international.org/14.0/#sec-iteratornext

Expand Down
2 changes: 1 addition & 1 deletion 2023/IteratorStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var $TypeError = require('es-errors/type');
var IteratorComplete = require('./IteratorComplete');
var IteratorNext = require('./IteratorNext');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

// https://262.ecma-international.org/14.0/#sec-iteratorstep

Expand Down
2 changes: 1 addition & 1 deletion 2023/IteratorToList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var $arrayPush = callBound('Array.prototype.push');
var IteratorStep = require('./IteratorStep');
var IteratorValue = require('./IteratorValue');

var isIteratorRecord = require('../helpers/records/iterator-record');
var isIteratorRecord = require('../helpers/records/iterator-record-2023');

// https://262.ecma-international.org/14.0/#sec-iteratortolist

Expand Down
2 changes: 1 addition & 1 deletion 2024/AsyncIteratorClose.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var callBound = require('call-bind/callBound');

var $then = callBound('Promise.prototype.then', true);

// https://262.ecma-international.org/12.0/#sec-asynciteratorclose
// https://262.ecma-international.org/15.0/#sec-asynciteratorclose

module.exports = function AsyncIteratorClose(iteratorRecord, completion) {
if (!isIteratorRecord(iteratorRecord)) {
Expand Down
2 changes: 1 addition & 1 deletion 2024/CreateAsyncFromSyncIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var $AsyncFromSyncIteratorPrototype = GetIntrinsic('%AsyncFromSyncIteratorProtot
}
};

// https://262.ecma-international.org/14.0/#sec-createasyncfromsynciterator
// https://262.ecma-international.org/15.0/#sec-createasyncfromsynciterator

module.exports = function CreateAsyncFromSyncIterator(syncIteratorRecord) {
if (!isIteratorRecord(syncIteratorRecord)) {
Expand Down
2 changes: 1 addition & 1 deletion 2024/IteratorClose.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');

// https://262.ecma-international.org/14.0/#sec-iteratorclose
// https://262.ecma-international.org/15.0/#sec-iteratorclose

module.exports = function IteratorClose(iteratorRecord, completion) {
if (!isIteratorRecord(iteratorRecord)) {
Expand Down
2 changes: 1 addition & 1 deletion 2024/IteratorNext.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var Type = require('./Type');

var isIteratorRecord = require('../helpers/records/iterator-record');

// https://262.ecma-international.org/14.0/#sec-iteratornext
// https://262.ecma-international.org/15.0/#sec-iteratornext

module.exports = function IteratorNext(iteratorRecord) {
if (!isIteratorRecord(iteratorRecord)) {
Expand Down
2 changes: 1 addition & 1 deletion 2024/IteratorStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var IteratorNext = require('./IteratorNext');

var isIteratorRecord = require('../helpers/records/iterator-record');

// https://262.ecma-international.org/14.0/#sec-iteratorstep
// https://262.ecma-international.org/15.0/#sec-iteratorstep

module.exports = function IteratorStep(iteratorRecord) {
if (!isIteratorRecord(iteratorRecord)) {
Expand Down
2 changes: 1 addition & 1 deletion 2024/IteratorToList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var IteratorValue = require('./IteratorValue');

var isIteratorRecord = require('../helpers/records/iterator-record');

// https://262.ecma-international.org/14.0/#sec-iteratortolist
// https://262.ecma-international.org/15.0/#sec-iteratortolist

module.exports = function IteratorToList(iteratorRecord) {
if (!isIteratorRecord(iteratorRecord)) {
Expand Down
2 changes: 1 addition & 1 deletion helpers/assertRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var $SyntaxError = require('es-errors/syntax');

var isMatchRecord = require('./records/match-record');
var isPropertyDescriptor = require('./records/property-descriptor');
var isIteratorRecord = require('./records/iterator-record');
var isIteratorRecord = require('./records/iterator-record-2023');
var isPromiseCapabilityRecord = require('./records/promise-capability-record');
var isAsyncGeneratorRequestRecord = require('./records/async-generator-request-record');
var isRegExpRecord = require('./records/regexp-record');
Expand Down
7 changes: 7 additions & 0 deletions helpers/records/iterator-record-2023.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

var isIteratorRecordNew = require('./iterator-record');

module.exports = function isIteratorRecord(value) {
return isIteratorRecordNew(value) && typeof value['[[NextMethod]]'] === 'function';
};
1 change: 0 additions & 1 deletion helpers/records/iterator-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = function isIteratorRecord(value) {
&& typeof value === 'object'
&& hasOwn(value, '[[Iterator]]')
&& hasOwn(value, '[[NextMethod]]')
&& typeof value['[[NextMethod]]'] === 'function'
&& hasOwn(value, '[[Done]]')
&& typeof value['[[Done]]'] === 'boolean';
};

0 comments on commit c7d7521

Please sign in to comment.