Merge pull request #18869 from bradcray/try-stmts-only
try statements accept more statement kinds and not arbitrary expressions
[reviewed by @dlongnecke-cray]
In #18859, @bmcdonald3 pointed out some strange behavior where a loop suddenly
generated an error when a
try! was applied to it. It turns out that this is because
try! grammar production accepted a general
expr at the statement level,
causing the loop to be interpreted as a loop expression rather than a loop statement.
It seems to me that a statement-level
try! should only be able to be applied
to statements and that an expression-level one should be applied to expressions.
Moreover, in digging into this a bit, it turns out that the only statement-level statements
try! can be applied to are the family of assignment statements. So here,
I split the
stmt production into what I called "executable" statements vs. non- (where
that's probably not the best adjective, but...) as a means of indicating which family of
statements seemed (to me anyway) to be ones that
try could be applied to. Checking
the spec to see how we described the syntax of
try!, I'm finding that the
spec doesn't even make an attempt at giving the syntax productions for these, which is...
disappointing, but not something I'm trying to fix here. I've opened issue #18938 to
continue to kick around the question of whether where I've left things is appropriate as
a placeholder for that effort.
Modified Files: A test/errhandling/stmtVsExpr.chpl