Open jmm opened 3 years ago
Absent an intervening line terminator, "a semicolon is required between a statement that ends with an expression and a statement [...]" is true regardless of the second statement, not just the given list. It really does need to talk about lines.
We could probably rephrase it in a way which makes it clear that the semicolon just has to be between the two, though, not necessarily at the end of the first line. And we should probably change "the following line" to "the following line of code" or something.
@bakkot thanks for reading and giving feedback.
You're right, but this section is in the context of cases where automatic semicolon insertion might happen, and as you noted there's no expectation that it would happen in the scenario without any intervening LineTerminators. So I don't think it's the responsibility of this section to exhaustively detail when it won't happen. But to be more specific, it could be phrased something like:
As a consequence of the rules above, a semicolon is required between StatementListItems when a StatementListItem that ends with an expression is followed by zero or more LineTerminators followed by a StatementListItem that begins with any of the following:
Or:
As a consequence of the rules above, a semicolon is required between a StatementListItem that ends with an expression and a StatementListItem that begins with any of the following, even when one or more LineTerminators appear between StatementListItems:
Or:
In some cases, a semicolon would be automatically inserted when a StatementListItem that ends with an expression is followed by one or more LineTerminators and a StatementListItem. However, as a consequence of the rules above, an explicit semicolon is required between StatementListItems when the second StatementListItem begins with any of the following:
Then the list items all reference "the two lines together". Maybe it would be simpler there to just say "the lines together".
Regarding this description:
It seems like it would be more accurate and clear to describe it in terms of statements like in section 11.9. Something like:
The current version seems as if it could imply a difference between cases like these:
Considering that the layout of lines actually is relevant in some cases, I think it would be good for clarity to describe this in terms of statements.