-
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: new Annex B.3 clause to specify "AssignmentTargetType of LeftHandSideExpression : CallExpression" web reality. #2193
base: main
Are you sure you want to change the base?
Conversation
See older discussion in #257. Note that both SpiderMonkey and JavaScriptCore make this an early error in strict code, so it should be safe to make this legal only in non-strict code. V8 has use counters for this pattern in both strict and non-strict code, which show almost no usage in strict code and a nontrivial amount of usage in non-strict code. |
I agree with @bakkot in #2193 (comment). Seems like a good idea to clean this up for strict, but too risky for non-strict. |
Do we instead want to put non-strict in the main body with an "icky" note? |
…eftHandSideExpression : CallExpression" web reality.
6f80175
to
4db9963
Compare
I've added the limitation to non-strict code, however I'm not sure the language is exactly right. |
The Early Errors in https://tc39.es/ecma262/#sec-assignment-operators-static-semantics-early-errors also need to be modified by Annex B to allow |
sending this again: Do we instead want to put this in the main body with an "icky" note? |
Thanks for following up with this PR, @rwaldron . It's too bad we all dropped it on the floor earlier. LGTM in its current form. Note that this version does not include logical assignment operators, and as such, V8 is banning this construct. (Apparently there are already test262 tests for this.) https://chromium-review.googlesource.com/c/v8/v8/+/2423721 . This prohibition seems appropriate to me, since it's not needed for compatibility. |
Hmm, I always feel like it's better not to make an already-unfortunate rule more complicated than it has to be. We can certainly get away with allowing |
Awareness by whom? |
Spec readers, I guess? I understand that users won't write this, and if they do they'll get an error sooner or later, but it seems odd to create two special rules when one will do—no one seems to benefit from the added complexity. |
3d0c24c
to
7a79833
Compare
Whew, four years have gone by. Am I correct in understanding that this is still what we'd want, it was just never presented in plenary? (I guess I was the most recent commenter here but I honestly don't feel that strongly about what I said at that time.) |
The intention of this change is to allow JS engines which run in browsers to be spec conformant in their handling of assignment to CallExpression Arguments. Both Chrome and Firefox have attempted to make the following a Syntax Error:
...However they were unable to do so without breaking the web! As it turns out, every engine that runs in a web browser has implemented the same behavior:
Note that non-browser embedded engines, which do not bear the same burden as the above engines, implement this according to the current specification:
I'd like to propose that TC39 codify the web reality. If there is a better way to define this, please advise!
cc @syg @jorendorff