An Arrow Parsing Edge Case

# Kevin Smith (11 years ago)

Given the following edge case contained in non-strict code:

function* g() { (yield) => null }

Is this a syntax error, or not?

The sequence (yield) will successfully parse as a parenthesized expression. If we re-parse as an arrow parameter list, do we view the "lexical token stream" as containing a yield keyword, or an identifier whose value is yield?

# Jason Orendorff (11 years ago)

yield is a keyword inside function* whether you're in strict or non-strict code.

So that is a syntax error.

# Kevin Smith (11 years ago)

yield is a keyword inside function* whether you're in strict or non-strict code.

Right, but not within the body of nested arrow functions:

function* g() { () => { var yield; } }

IIUC, this would parse fine. So I'm asking whether a "yield" in the token stream for an arrow parameter list should be interpreted as a keyword or an identifier when we do the rewind/transform dance.

# Allen Wirfs-Brock (11 years ago)

See bug ecmascript#2504

My current spec draft disallows 'yield' as a arrow function parameter when the arrow function is directly within a generator function.