tc39 / proposal-do-expressions

Proposal for `do` expressions
MIT License
1.11k stars 14 forks source link

EndsInIterationOrBareIfOrDeclaration missing case: Block with statements #68

Closed Jack-Works closed 3 years ago

Jack-Works commented 3 years ago

Only Block with no statements inside is mentioned.

bakkot commented 3 years ago

This is covered by the chain production rule:

Unless explicitly specified otherwise, all chain productions have an implicit definition for every operation that might be applied to that production's left-hand side nonterminal. The implicit definition simply reapplies the same operation with the same parameters, if any, to the chain production's sole right-hand side nonterminal and then returns the result.

Jack-Works commented 3 years ago

I implement this as:

if (isBlock(node)) return checkEndsInIterationOrBareIfOrDeclaration(node.statements, labelSet, isLast);

Is this correct?

bakkot commented 3 years ago

As long as you handle the case that the list of statements is empty, yes. That's what I do.