-
-
Notifications
You must be signed in to change notification settings - Fork 392
-
-
Notifications
You must be signed in to change notification settings - Fork 392
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
Agree and document the meaning of ReferenceFlags::Read
and Write
#5165
Comments
I have a simple idea. const x = {
get value() {
console.log('read');
},
set value(v) {
console.log('write');
}
} For example, with |
I like that - it's easy to understand. So by that definition of "read" and "write", let x = {
get value() { console.log('read'); },
set value(v) { console.log('write'); },
};
++x.value; But... I am still wondering what the purpose of the read and write flags is? What are they meant to be used for? That might affect what is the right mental model to have. |
https://tc39.es/ecma262/#sec-prefix-increment-operator-runtime-semantics-evaluation This is the semantics of read and write. |
So do I understand right that the flags we currently have on Either way, am reopening this issue as the "action" I was requesting is that we document it. |
You may need to update the issue title and description. |
ReferenceFlags::Read
mean?ReferenceFlags::Read
and Write
Have changed the issue title. To (hopefully) conclude this, have I understood correctly from spec above that |
yes |
Thank you. I'll add some docs, and open an issue to fix flags on |
This question came up previously in #3326, and has reared its head again in #5158.
++x
currently gets flagged asWrite
only.This doesn't make sense to me as it is equivalent to
x += 1
which isRead | Write
.The tests indicate this is intentional, but the reason why is not documented anywhere.
@Dunqing's guess was "I believe this variable can be safely removed by the Minifier/Compressor."
But as I pointed out,
++x
can have side effects ifx
is an object with avalueOf
method:So that suggests that
++x
cannot be removed by minifier in all cases.Whatever the rationale is, can we please hash it out and document it?
The text was updated successfully, but these errors were encountered: