Skip to content

Instantly share code, notes, and snippets.

@lukehoban
Created January 28, 2014 23:00
Show Gist options
  • Save lukehoban/8678463 to your computer and use it in GitHub Desktop.
Save lukehoban/8678463 to your computer and use it in GitHub Desktop.
Precedence of `yield` in ES6
// Current ES spec grammar
1 + yield //  error
1 + yield 2 //  error
yield + 1 // yield (+1)
yield 1 + yield 2 // error
yield(1) + yield(2) // error
yield 1 + 2 // yield (1+2)
yield * yield // (yield *) yield
yield + yield // error

// C# await grammar
1 + yield //  1 + (yield)
1 + yield 2 //  1 + (yield 2)
yield + 1 // (yield) + 1
yield 1 + yield 2 // (yield 1) + (yield 2)
yield(1) + yield(2) // (yield(1)) + (yield(2))
yield 1 + 2 // (yield 1) + 2
yield * yield // (yield) * (yield)
yield + yield // (yield) + (yield)

I believe the await style precendence is more expected in all but one case. Certainly a ES7 await would align with the C# precendence. But are we sure that ES6 yield shouldn't also match?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment