tc39 / proposal-explicit-resource-management

ECMAScript Explicit Resource Management
https://arai-a.github.io/ecma262-compare/?pr=3000
BSD 3-Clause "New" or "Revised" License
725 stars 28 forks source link

Identity cover grammar #224

Open waldemarhorwat opened 2 months ago

waldemarhorwat commented 2 months ago

The CoverAwaitExpressionAndAwaitUsingDeclarationHead and AwaitExpression grammars are identical, so I'm curious about the editorial decision to reparse in that case.

The proposal includes instances of static semantics reparsing a CoverAwaitExpressionAndAwaitUsingDeclarationHead as an AwaitExpression, and generating an error if that fails, but it can't fail.

I assume the reason to keep the cover conceptually separate from the identical covered grammar is so that assertions like that in AwaitExpression work cleanly; if so, an informative note might be in order.

rbuckton commented 2 months ago

@syg, @michaelficarra, @bakkot do you have thoughts on this? Is it worth leaving the cover in?

syg commented 3 weeks ago

I was similarly confused by this. I think even had to ask @rbuckton to explain why it's the same grammar. Definitely worth at least a note. I think on net, having an identical-in-content-but-differently-named production is a positive on readability. I don't know of a better way to do it in any case.

waldemarhorwat commented 3 weeks ago

If all you want is an identical-in-content-but-differently-named production, you might not need a cover grammar. A production that expands to another production might work.