-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Reference type and implementation reality #467
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
Comments
There is no resolution, and further the deviation continues to exist. I think if we want to change this it should be a full proposal because it is a core part of the semantics and changing this has been very controversial in the past. The difficult part in my mind is that the current spec seems correct and the biggest argment in favor of fixing this problem is that it's hard for implementations to do so. Maybe that's enough? |
For reference, here's a couple of simple tests, with results on current (public) builds of various engines (ETA: and some older browsers). The current spec dictates that both should have
Prefix and postfix increment and decrement all behave identically on a given platform, as do all of the compound assignment operators. Per the above, the only variation is that SpiderMonkey only performs ETA: I've added older versions of Chrome, Firefox, and Internet Explorer, in the interests of knowing how long-standing this is. IE6 and IE8, uniquely among the browsers I've tested, conform to the spec as it then stood and still stands. |
@bakkot Would you be interested in writing up a proposal for a spec change here? Or do you prefer the semantics of the spec? |
@littledan - I much prefer the semantics in the spec. The situation in question seems similar to |
@bakkot No, |
@littledan, right, that's my objection to changing the spec. To the user it appears that there is a single operation being performed, which is getting the name of the property. For half of that step to be repeated seems overcomplicated and confusing. Since |
@bakkot Curious, considering that implementations have had this bug for two decades now, do you want the spec to continue to say something implementers aren't motivated to fix and might not be web-compatible, or would you prefer the spec to reflect reality of what implementers do and the web (and other code) may depend on? |
@bterlson, I have no strong feelings either way. I'd be surprised to learn anyone was particularly depending on the current behavior, though, both because of that one SpiderMonkey difference above and because I believe it's rare to have side-effecting |
@bakkot, thanks this is helpful. For what it's worth, I don't think there is any (or much) disagreement that the spec text is currently better than how implementations behave. The problem is that this is a long-standing deviation implementations have and even for an edge case like this the likelihood of the web depending on this behavior seems high. The problem is that an implementation will have to proceed carefully under the assumption that this pattern exists on the web, and that's the hard issue to work around. I'm not sure any of us are willing to go through the motions for this. |
@bterlson: In the interests of knowing how likely it is that anyone is depending on this... it turns out that IE6 and IE8 got this right, that is, they conform to spec. I'll try to test some other browsers when I get a chance. ETA: Done; see updated table. IE8 conforms to spec, IE10 does not. The oldest versions of Chrome and Firefox I have easy access to do not conform. |
Eric just fixed the |
My recollection (I could be wrong) the last time TC39 discussed this issue at a meeting, we decided to retain the current (and legacy) spec. language. I meeting notes search (it may predate github notes) would be required to verify that. |
@bterlson, of historical interest: Opera 9 (March 2009) got this right (conforms to the spec), as did likely Opera versions going back to Opera 7 at least (ca 2004). Opera 12 gets it wrong. (I only tested the ++ case but IIRC this was all handled through some ToPropertyKey type operation in the bytecode for RMW ops in the older engine.) |
Another interesting testcase (related to tc39/test262#273): var hits = '';
var base = {};
var prop = function () {
hits += 'A';
return { toString: function () { hits += 'B'; } };
}
var expr = function () {
hits += 'C';
}
base[prop()] = expr();
hits; Expected: Old Opera 9 had it right ( Changing the spec to match current implementations might be tricky, as it implies to split the algorithm in 12.3.2.1 in two parts: steps 1-4 produces |
When this was discussed at TC39, it seemed like the resolution was to stick with the current spec, pending Mozilla shipping its implementation and demonstrating that it was web-compatible. Microsoft emphasized that fixing the bug on their side was low priority. @efaust How has shipping that patch gone? Do you pass the test that @claudepache mentioned? |
@claudepache IE6/IE8 return |
@evilpie @jswalden can you reply to #467 (comment), perhaps? I get the following results today with #### Chakra
2
#### JavaScriptCore
2
#### SpiderMonkey
1
#### V8
2 which suggests that "2" is in fact the web reality, and is what should be specified. @bakkot are you willing to write the PR? |
You mean in addition to the one from above #467 (comment)? A related one is:
Spec: "A" I think this issue is simply super-low priority for implementers, because it's too obscure to make any difference in practice and the cost benefits are too small to justify putting any efforts in it to change an implementation. But I'm also not sure if that justifies that the spec has to change, especially because it's not a one-line change what's needed here (as already mentioned above by Claude). |
I agree with @anba -- this is just low priority for people to fix. I don't think that alone justifies changing sensible spec semantics. |
It seems important that the spec match what engines actually do; if there's a way to decrease that gap (even if it's too low a priority for the resulting minority of "incorrect" implementations to ever fix), it seems worth making the change in a general sense. |
…tc39#2094) Verify binding existence in the object's SetMutableBinding on Strict Mode. Closes tc39#2093 Ref tc39#467 Ref tc39/test262#427
Currently, JSC, V8, SM, and XS all *do not throw* on the following code, contra spec: ```javascript "use strict"; undeclared = (this.undeclared = 42); ``` This has been a bug in implementations for a decade (https://bugzilla.mozilla.org/show_bug.cgi?id=605515), and is arguably implementation reality not only for the web but for most implementations. This changes the spec to match the implemented re-resolution behavior. Also see - tc39#467 - tc39/test262#1964
Does anyone have an idea of a resolution on this bug in the old repository?
https://bugs.ecmascript.org/show_bug.cgi?id=4379
Quoting @anba
@ajklein
The text was updated successfully, but these errors were encountered: