Fix errors in intrinsics
MODIFY
packages/intrinsics-whitelist/src/whitelist.js
packages/intrinsics-whitelist/src/whitelist.js
@@ -1512,20 +1512,20 @@ export default {
// ESNext
- // New intrinsic.
- 'FunctionPrototypeConstructor': {
+ // New intrinsic like %Function% but disabled.
+ FunctionPrototypeConstructor: {
'**proto**': 'FunctionPrototype',
length: 'number',
prototype: 'FunctionPrototype',
},
- Constructor: {
+ Compartment: {
'**proto**': 'FunctionPrototype',
- prototype: 'ConstructorPrototype',
+ prototype: 'CompartmentPrototype',
},
- ConstructorPrototype: {
- constructor: 'Constructor',
+ CompartmentPrototype: {
+ constructor: 'Compartment',
evaluate: fn,
global: getter,
},

MODIFY
packages/intrinsics/src/main.js
packages/intrinsics/src/main.js
@@ -164,11 +164,11 @@ const intrinsicNames = [
];
/**
- * validateAnonIntrinsics()
+ * checkAnonIntrinsics()
* Ensure that the rootAnonIntrinsics are consistent with specs. These
* tests are necesary to ensure that sampling was correctly done.
*/
-function validateAnonIntrinsics(intrinsics) {
+function checkAnonIntrinsics(intrinsics) {
const {
FunctionPrototypeConstructor,
ArrayIteratorPrototype,
@@ -320,7 +320,6 @@ function validateAnonIntrinsics(intrinsics) {
* traversal from the global object.
*/
function getAnonymousIntrinsics() {
-
const FunctionPrototypeConstructor = Function.prototype.constructor;
const SymbolIterator = (typeof Symbol && Symbol.iterator) || '@@iterator';
@@ -414,7 +413,7 @@ function getAnonymousIntrinsics() {
TypedArray,
};
- validateAnonIntrinsics(intrinsics);
+ checkAnonIntrinsics(intrinsics);
return intrinsics;
}
@@ -436,6 +435,18 @@ function getNamedIntrinsic(root, name) {
return desc.value;
}
+/**
+ * checkIntrinsics()
+ * Ensure that the intrinsics are consistent with defined.
+ */
+function checkIntrinsics(intrinsics) {
+ Object.keys(intrinsics).forEach(name => {
+ if (intrinsics[name] === undefined) {
+ throw new TypeError(`Malformed intrinsic: ${name}`);
+ }
+ });
+}
+
const suffix = 'Prototype';
/**
@@ -489,11 +500,7 @@ export function getIntrinsics() {
}
}
- Object.keys(intrinsics).forEach(name => {
- if (intrinsics[name] === undefined) {
- throw new TypeError(`Malformed intrinsic: ${name}`);
- }
- });
+ checkIntrinsics(intrinsics);
return intrinsics;
}

Fix errors in intrinsics