`yield` expressions aren't parsed correctly when used with arrays or with `yield*`
Monkatraz opened this issue · comments
You can tell it's not being parsed correctly because the yield
keyword isn't being highlighted as a keyword sometimes.
Looking at the grammar, it's definitely clear that yield*
is simply not being handled. I'm not sure what's going on with the array case though, maybe just a dynamic precedence thing?
It looks like yield [valid_array]
is parsed as MemberExpression
, considering yield
a variable in this context. yield*
is generally parsed as BinaryExpression
.
Indeed, the parser was exploring both the case where yield
(or await
) was a keyword, and the case where it acted as a variable. For yield [1]
both were valid, and we needed dynamic precedence to make the outcome predictably choose the keyword rule. Attached patch does this (and adds yield*
support).