From 1dc3609ff22e6a7be4d86d2ba983f81dfd8c1fd4 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Sun, 15 Jan 2023 13:26:05 +0900 Subject: fix(core): Add `Generator` and `AsyncGenerator` to promordials (#17241) --- core/00_primordials.js | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'core/00_primordials.js') diff --git a/core/00_primordials.js b/core/00_primordials.js index 33d7299d5..d394d1294 100644 --- a/core/00_primordials.js +++ b/core/00_primordials.js @@ -248,24 +248,6 @@ copyPrototype(original.prototype, primordials, `${name}Prototype`); }); - const { - ArrayPrototypeForEach, - ArrayPrototypeMap, - FunctionPrototypeCall, - Map, - ObjectDefineProperty, - ObjectFreeze, - ObjectPrototypeIsPrototypeOf, - ObjectSetPrototypeOf, - Promise, - PromisePrototype, - PromisePrototypeThen, - Set, - SymbolIterator, - WeakMap, - WeakSet, - } = primordials; - // Create copies of abstract intrinsic objects that are not directly exposed // on the global object. // Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object @@ -295,6 +277,11 @@ prototype: Reflect.getPrototypeOf(String.prototype[Symbol.iterator]()), }, }, + { name: "Generator", original: Reflect.getPrototypeOf(function* () {}) }, + { + name: "AsyncGenerator", + original: Reflect.getPrototypeOf(async function* () {}), + }, ].forEach(({ name, original }) => { primordials[name] = original; // The static %TypedArray% methods require a valid `this`, but can't be bound, @@ -303,6 +290,20 @@ copyPrototype(original.prototype, primordials, `${name}Prototype`); }); + const { + ArrayPrototypeForEach, + ArrayPrototypeMap, + FunctionPrototypeCall, + ObjectDefineProperty, + ObjectFreeze, + ObjectPrototypeIsPrototypeOf, + ObjectSetPrototypeOf, + Promise, + PromisePrototype, + PromisePrototypeThen, + SymbolIterator, + } = primordials; + // Because these functions are used by `makeSafe`, which is exposed // on the `primordials` object, it's important to use const references // to the primordials that they use: -- cgit v1.2.3