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

[[GetOwnProperty]] on module namespace exotic object returns writable: true, but [[Set]] is a noop #749

Open
Kovensky opened this Issue Dec 8, 2016 · 8 comments

Comments

Projects
None yet
3 participants
@Kovensky

Kovensky commented Dec 8, 2016

This means that it actually is not possible to write to the property. It is not configurable or extensible too so [[DefineOwnProperty]] would fail, but it's defined to do nothing on module namespace exotic objects too so that's also out.

See https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects-getownproperty-p and https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects-set-p-v-receiver

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Dec 8, 2016

Member
Member

allenwb commented Dec 8, 2016

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Dec 8, 2016

Member

Would another alternative be, making it a non-writable getter? Or would that create performance implications we wish to avoid?

Member

ljharb commented Dec 8, 2016

Would another alternative be, making it a non-writable getter? Or would that create performance implications we wish to avoid?

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Dec 8, 2016

Member
Member

allenwb commented Dec 8, 2016

@Kovensky

This comment has been minimized.

Show comment
Hide comment
@Kovensky

Kovensky Dec 8, 2016

The problem is that the value of the property cannot observably change, or at least its identity is fixed at creation time and cannot be changed, so the invariant is not violated for live bindings even with writable: false.

If a property P is described as a data property with Desc.[[Value]] equal to v and Desc.[[Writable]] and Desc.[[Configurable]] are both false, then the SameValue must be returned for the Desc.[[Value]] attribute of the property on all future calls to [[GetOwnProperty]] ( P ).

Even if the value is an object reference, while the object itself may be internally mutated, the result of SameValue will never change.

EDIT: ah, since [[Get]] fetches the value directly from the other module's environment record, the value might indeed change if it is not a const... 😕

This does also mean, though, that non-engine implementations (webpack, babel, etc) cannot implement the module record without actually using getters / chains of getters.

Kovensky commented Dec 8, 2016

The problem is that the value of the property cannot observably change, or at least its identity is fixed at creation time and cannot be changed, so the invariant is not violated for live bindings even with writable: false.

If a property P is described as a data property with Desc.[[Value]] equal to v and Desc.[[Writable]] and Desc.[[Configurable]] are both false, then the SameValue must be returned for the Desc.[[Value]] attribute of the property on all future calls to [[GetOwnProperty]] ( P ).

Even if the value is an object reference, while the object itself may be internally mutated, the result of SameValue will never change.

EDIT: ah, since [[Get]] fetches the value directly from the other module's environment record, the value might indeed change if it is not a const... 😕

This does also mean, though, that non-engine implementations (webpack, babel, etc) cannot implement the module record without actually using getters / chains of getters.

@Kovensky

This comment has been minimized.

Show comment
Hide comment
@Kovensky

Kovensky Dec 8, 2016

There is nothing buggy about an exotic object that is writable: false yet throws in a [[Set]].

The problem here is the inverse; it is writable: true yet throws in a [[Set]].

Kovensky commented Dec 8, 2016

There is nothing buggy about an exotic object that is writable: false yet throws in a [[Set]].

The problem here is the inverse; it is writable: true yet throws in a [[Set]].

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb

allenwb Dec 8, 2016

Member

@Kovensky

The problem here is the inverse; it is writable: true yet throws in a [[Set]].

oops, typo. Meant writable: true. Corrected.

Member

allenwb commented Dec 8, 2016

@Kovensky

The problem here is the inverse; it is writable: true yet throws in a [[Set]].

oops, typo. Meant writable: true. Corrected.

@allenwb

This comment has been minimized.

Show comment
Hide comment
@allenwb
Member

allenwb commented Dec 8, 2016

@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Mar 21, 2018

Member

This seems answered; OK to close?

Member

ljharb commented Mar 21, 2018

This seems answered; OK to close?

@ljharb ljharb added the question label Mar 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment