tc39 / proposal-do-expressions

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

Spec needs to handle empty completion values #48

Closed bakkot closed 3 years ago

bakkot commented 4 years ago

For example, do { ; } has a completion value of { [[Type]]: normal, [[Value]]: empty, [[Target]]: empty }. But empty is not a value which can actually be used in an expression. That case needs to be handled explicitly, as in step 27 of PerformEval:

  1. If result.[[Type]] is normal and result.[[Value]] is empty, then a. Set result to NormalCompletion(undefined).
bakkot commented 4 years ago

In https://github.com/tc39/proposal-do-expressions/issues/21#issuecomment-359878642 @allenwb says

The do expression do {} needs to evaluate to [[Type]]: normal, [[Value]]: empty so it has Tennant's correspondence with { } when used in a statement context.

I disagree with this; I think it's fine for (do { 0; (do {}); }) to be undefined instead of 0, despite the Tennant's correspondence violation.

bakkot commented 3 years ago

This is done (in particular by the call to UpdateEmpty).