New Issue: Single-keyword statement forms and 'do'?

19181, "bradcray", "Single-keyword statement forms and 'do'?", "2022-02-04T02:32:28Z"

In Chapel, some of our nested statement forms use do to make it clear where the statement's "header" ends and where the single-statement "body" statement starts. For example:

while testExpr do ...

For a multi-statement body, a compound statement / curly brackets can be used:

while testExpr { ... }

And since a compound statement is a single statement, the two can be mixed (though this tends not to be preferred style):

while testExpr do { ... }

Other nested statement forms don't require a do because it's obvious where the statement begins (typically because nothing other the statement can follow the keyword). For example:

begin mySingleStmt();

is supported, as is:

begin { ... }

since the compound statement is a single statement. However,

begin do mySingleStmt();

isn't currently supported. This issue asks whether we should permit such statements to use the do, even though it's not necessary, simply so that users who lean more on do won't have to learn or remember when it is or is not legal.

With a quick scan of the grammar, I think that begin and sync are the two main statement forms that are lacking the do option currently, though I could be missing some. try/try! also potentially are in this category, though they seem different to me somehow (though I'm not sure why).