-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Normative: Restriction on [[Prototype]] of the global object #1967
base: main
Are you sure you want to change the base?
Conversation
@@ -24800,6 +24800,7 @@ <h1>The Global Object</h1> | |||
<li>does not have a [[Construct]] internal method; it cannot be used as a constructor with the `new` operator.</li> | |||
<li>does not have a [[Call]] internal method; it cannot be invoked as a function.</li> | |||
<li>has a [[Prototype]] internal slot whose value is implementation-dependent.</li> | |||
<li>is an instance of the standard built-in Object constructor.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is “is an instance of the standard built-in Object constructor” an observable status / a defined concept?
I’m guessing the intention here is to say that the [[Prototype]] chain (initially? permanently?) includes %Object.prototype%, which is not the same thing as being an instance of a given constructor as this phrase is used elsewhere. For example,
[A Boolean Object is] a member of the Object type that is an instance of the standard built-in Boolean constructor.
It’s observable (indirectly) that an object is a Boolean Object because the [[BooleanData]] slot is obtained uniquely through creation with the Boolean constructor. It’s incidental that such an object likely has %Boolean.prototype% as its [[Prototype]], and it may not — Object.setPrototypeOf(new Boolean, null)
is still a Boolean Object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with your opinion. The sentence "is instance of the the standard built-in Object constructor" does not clearly imply that the prototype chain includes %Object.prototype%. Thus, I just directly wrote that the prototype chain include %Object.prototype% and updated the pull request.
this is normative, not editorial. |
Thank you for the correction, I revised the name of the pull request. |
@@ -24799,7 +24799,7 @@ <h1>The Global Object</h1> | |||
<li>is created before control enters any execution context.</li> | |||
<li>does not have a [[Construct]] internal method; it cannot be used as a constructor with the `new` operator.</li> | |||
<li>does not have a [[Call]] internal method; it cannot be invoked as a function.</li> | |||
<li>has a [[Prototype]] internal slot whose value is implementation-dependent.</li> | |||
<li>has a [[Prototype]] internal slot whose value is implementation-dependent but the prototype chain includes %Object.prototype%.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the challenges here might be that %Object.prototype%
is a Realm-specific value, but i believe the WindowProxy causes the current realm's Object.prototype
to report as being in the prototype chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WindowProxy.[[GetPrototypeOf]]()
returns null
for cross‑origin calls, which are a subset of cross‑realm calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right - and null
doesn't have Object.prototype
in its prototype chain.
Good catch! If it's not possible to make this assertion about all JS environments, another way to go about ensuring the accuracy of the tests would be to make a piece of metadata in the test262 tests indicating, "these tests are valid for environments where Object.prototype is in the prototype chain of the global object". |
Well, within the realm of the global object, the global object’s prototype will always include |
It's not really clear to me what an assertion like "the prototype chain includes" means when the prototype chain is queried by |
3d0c24c
to
7a79833
Compare
According to the issue in Test262 repository, Test262 provides the following tests that assume that the global object is an instance of the built-in Object constructor:
@ljharb said in the comment:
Thus, I added one restriction to the global object which is "the global object should be an instance of the standard built-in Object constructor.