tc39 / ecma262

Status, process, and documents for ECMA-262
https://tc39.es/ecma262/
Other
15.05k stars 1.28k forks source link

Stale note in Rules of ASI about restricted productions #1807

Open bathos opened 4 years ago

bathos commented 4 years ago

In Rules of Automatic Semicolon Insertion, there’s a note which begins “The following are the only restricted productions in the grammar.” It then lists seven of the sixteen restricted productions. The missing ones are:

I’m not sure it’s practical to list all of them. I think maybe the note ought to be removed or reworked so that it’s illustrative rather than (supposedly) comprehensive.

The productions repeated here are also inconsistent: some include their alternatives that don’t use NLTH, while others omit them.

bathos commented 4 years ago

On reflection I think maybe some of these omissions are sensible because they aren’t cases where ASI would successfully apply. It’s unclear to me whether the definition of restricted production is ‘a production that includes [no LineTerminator here]’ or if it is ‘a production that includes [no LineTerminator here] where, if a line terminator did occur in that position, ASI would produce a valid result.’

In any case, some of the omitted items do fall within the latter, narrower category, e.g. AsyncFunctionDeclaration.

Edit: The term "restricted production" is defined explicitly and it does appear to include all 16:

If the phrase “[no LineTerminator here]” appears in the right-hand side of a production of the syntactic grammar, it indicates that the production is a restricted production: it may not be used if a LineTerminator occurs in the input stream at the indicated position.

ljharb commented 4 years ago

1062 has just landed; if there's still changes you think should be made, a PR would be most helpful!

bathos commented 4 years ago

Thanks. The note that I’m talking about is left unchanged by that PR I think — it still says ‘the following are the only...’ but then doesn’t actually list all of them.

I’ll try my hand at a PR to revise this text, though I’d like to know first which of the following makes more sense to people:

ljharb commented 4 years ago

Updating the list to be comprehensive was the desired goal of #1193; that seems to be the proper path.