[SR-2605] Cascading failures trying to parse if <expr> else
#45210
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
good first issue
Good for newcomers
parser
Area → compiler: The legacy C++ parser
Additional Detail from JIRA
md5: 4700a3a0330dc628a2226b9d21b6eb4b
Issue Description:
If you're refactoring a
guard
into anif
, it's easy to accidentally end up with invalid code like this in the transition:The parser rightly complains about the
else
, but has poor recovery afterward, interpreting the following brace as a closure, which may in turn lead to other unhelpful errors after:It might be friendlier to recognize this pattern and instead recover as if the
else
wasn't there, or as if there were an empty block before it.The text was updated successfully, but these errors were encountered: