Skip to content

Commit 026bebf

Browse files
guybedfordtargos
authored andcommitted
bootstrap: --frozen-intrinsics unfreeze console
PR-URL: #27663 Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent d21e066 commit 026bebf

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

doc/api/cli.md

+34-4
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,41 @@ Support is currently only provided for the root context and no guarantees are
211211
currently provided that `global.Array` is indeed the default intrinsic
212212
reference.
213213

214-
**Code breakage is highly likely with this flag**, especially since limited
215-
support for subclassing builtins is provided currently due to ECMA-262 bug
216-
https://github.com/tc39/ecma262/pull/1320.
214+
**Code breakage is highly likely with this flag**, since redefining any
215+
builtin properties on a subclass will throw in strict mode due to the ECMA-262
216+
issue https://github.com/tc39/ecma262/pull/1307. This flag may still change
217+
or be removed in the future.
218+
219+
To avoid these cases, any builtin function overrides should be defined upfront:
220+
221+
<!-- eslint-disable no-redeclare -->
222+
```js
223+
const o = {};
224+
// THROWS: Cannot assign read only property 'toString' of object
225+
o.toString = () => 'string';
226+
227+
// OK
228+
const o = { toString: () => 'string' };
229+
230+
class X {
231+
constructor() {
232+
this.toString = () => 'string';
233+
}
234+
}
235+
// THROWS: Cannot assign read only property 'toString' of object
236+
new X();
237+
238+
class X {
239+
toString = undefined;
240+
constructor() {
241+
this.toString = () => 'string';
242+
}
243+
}
244+
// OK
245+
new X();
246+
```
247+
217248

218-
Both of the above may change in future updates, which will be breaking changes.
219249

220250
### `--heapsnapshot-signal=signal`
221251
<!-- YAML

lib/internal/freeze_intrinsics.js

-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ module.exports = function() {
3232
setInterval,
3333
setTimeout
3434
} = require('timers');
35-
const console = require('internal/console/global');
3635

3736
const intrinsics = [
3837
// Anonymous Intrinsics
@@ -136,7 +135,6 @@ module.exports = function() {
136135
setImmediate,
137136
setInterval,
138137
setTimeout,
139-
console,
140138

141139
// Other APIs
142140
BigInt,

0 commit comments

Comments
 (0)