tc39/proposal-exponentiation-operator

casual breaking change from earlier versions of ECMAScript?

saurik opened this issue · 3 comments

So... the expression ++++a used to be "supported": it would throw a RuntimeException if executed, but the script would parse without issue. This new specification breaks the entire script if this construct appears anywhere. I am not fundamentally against you doing this, but you definitely will need to add to the "incompatibilities with previous versions of ECMAScript" part of the specification if you move ahead. For this particular case, it is avoidable: just add a PrefixExpression that has ++/-- between UnaryExpression and PostfixExpression instead of trying to merge ++/-- down into the same level.

That said, it is actually "worse" than just that, because by putting an operator precedence level between ++ and + you also are breaking a lot of other "incorrect" but "at least the rest of the script parsed" code. I am personally less bothered by this (as ++++a is totally legit C and something I can see a lot of people would expect to work: when I first looked at ECMAScript a long long time ago, I myself was surprised that that didn't work, given the overall semantics of the language). I guess you might could add some kind of crazy backwards-compatibility production to the grammar.

FWIW, I would think that if you are going to make this kind of breaking change, you should do it as a top-level, stand-alone specification, with all the data miner people scavenging for where it will break things; and you then actually fix the underlying grammar problem: that "++a()" and "a() = 0" are legal constructs. Randomly deciding that "++++a" should be axed without gunning for "++a()" is strange. (Though from my personal perspective, both of these should not be touched, as I see no reason to go out of one's way at this point to demand that a() and ++a can never, even in the future, return references.)

Again: I'm not against this or anything, but it seems strange that people are just shoving it forward without any even momentary discussion of "will this break any websites?" and without any marking that "this is a breaking change from every previous version of ECMAScript". It might be that I'm just not finding all the discussion (as I'm having a difficult time integrating the apparently-infinite number of fragmented places, apparently included personal non-tc39 repositories on GitHub, people discuss this stuff), so if this was discussed I'm terribly sorry for missing it, but can I see a link? ;P

There is no breakage to existing valid grammar

Interesting: I had not noticed that this behavior seems to have changed in ECMAScript 6. I am terribly sorry for filing an issue with this syntax extension: you are correct that this is not a breaking change since ECMAScript 6. It is definitely a breaking change, however, since ECMAScript 5, and it is not marked as being an incompatible change (which is why I missed this). I will file this instead as a bug against the ECMAScript 6 specification's Annex E. Again, I am truly terribly sorry for the incorrect issue spam :(.

No worries!