From 554ffa34320ebfe62e6eefd4607483866362efd3 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sun, 16 Jun 2019 23:00:17 +0200 Subject: [PATCH] bootstrap: --frozen-intrinsics override problem workaround PR-URL: https://github.com/nodejs/node/pull/28254 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/cli.md | 39 +--- lib/internal/freeze_intrinsics.js | 238 ++++++++++++++++++++---- test/parallel/test-freeze-intrinsics.js | 21 +++ 3 files changed, 225 insertions(+), 73 deletions(-) diff --git a/doc/api/cli.md b/doc/api/cli.md index 4bf6a9473a0350..52270d69c5926b 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -209,44 +209,7 @@ Enable experimental frozen intrinsics like `Array` and `Object`. Support is currently only provided for the root context and no guarantees are currently provided that `global.Array` is indeed the default intrinsic -reference. - -**Code breakage is highly likely with this flag**, since redefining any -builtin properties on a subclass will throw in strict mode due to the ECMA-262 -issue https://github.com/tc39/ecma262/pull/1307. This flag may still change -or be removed in the future. - -To avoid these cases, any builtin function overrides should be defined upfront: - -```js -const o = {}; -// THROWS: Cannot assign read only property 'toString' of object -o.toString = () => 'string'; - -class X { - constructor() { - this.toString = () => 'string'; - } -} -// THROWS: Cannot assign read only property 'toString' of object -new X(); -``` - -```js -// OK -const o = { toString: () => 'string' }; - -class X { - toString = undefined; - constructor() { - this.toString = () => 'string'; - } -} -// OK -new X(); -``` - - +reference. Code may break under this flag. ### `--heapsnapshot-signal=signal`