ES6 grammar for for-loops
That line of code looks like it came directly from a test I wrote for kangax's ES6 compatibility table. Let's look at the test in its entirety:
try { eval('for (var i = 0 in {}) {}'); } catch(e) { return true; }
The grammer you describe is correct: ES6 no longer supports this useless
form. So, a conforming implementation must throw an error when the eval()
string is evaluated. If it does so, the test returns true
, signifiying
conforming support.
I hope that answers your question - and pardon my presumptions if this test code wasn't what you were thinking of at all.
Ok. Thanks for confirming our read of the grammar. Is this shown on any breaking changes list anywhere?
It should be -- who is maintaining such a list?
Cc'ing Oliver, I believe he found a for (var x = i in o)
use in the
wild but it was evangelized successfully. Mike Taylor may have helped,
cc'ing him too.
people.mozilla.org/~jorendorff/es6-draft.html#sec-in-edition-6 and people.mozilla.org/~jorendorff/es6-draft.html#sec-in-the-6th-edition
the above is the 7th item on the second list.
But I know, there are some things still missing from these lists so please file a bug if you know of a breaking change that is missing
For the following code:
for (var i = 0 in {}) { }
We are trying to figure out what grammar productions allow the left hand side of a for-in statement to have an initializer.
I notice that in the ES5 spec, the following productions can get you there:
But in ES6, all I see is
And neither BindingIdentifier or BindingPattern allow an initializer.
Is there a grammar path that I am missing?