From e6070556939106b5c514bfee57250a48a352a6c7 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 fe790a43bb2f91..6d39563c427f31 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`