-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vm Context literals do not use global constructors #3907
Comments
The wording in the spec is (https://tc39.es/ecma262/#sec-arraycreate):
The % notation is used to refer to language builtins (which are fixed per-realm), not JS expressions (https://tc39.es/ecma262/#sec-well-known-intrinsic-objects):
|
Thanks for educating @addaleax! |
@feugy Yes, exactly 👍 |
Ah, that's a shame 😭 |
Details
When running code inside a V8 context, and as explained in the documentation, the context comes with its own set of built-in constructors, like
Array
,Object
andFunction
.Many people got tricked because constructors in context realm are different from the Node.js ones (see resolved discussion #2880):
However, it is possible to override the context built-ins by providing the ones from Node.js realm upon creation:
This works as expected, except in one situation: array/object/function/regexp literals. These ones do not use provided constructors:
The later is (in my understanding of the spec) a bug:
__proto__
toArray.prototype
Array.prototype
comes from the global objectglobal.Array
should be the one provided (Node.js realm), and it seems it's not (context realm)instanceof
finds a mismatch whereas they should be the sameNode.js version
since v6 at least
Example code
Operating system
OSX
Scope
runtime
Module and version
vm
The text was updated successfully, but these errors were encountered: