mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Parse] Fix up a few places where we weren't propagating parse error status correctly.
We were always dropping the error status when returning from parseExprImpl. We were also incorrectly keeping error status after recovering by finding the right close token in parseList. This change fixes both, and also updates a few callers of parseList that assumed when they reported a failure parsing an element the list as a whole would get error status, which isn't true due to recovery.
This commit is contained in:
@@ -1118,8 +1118,14 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
|
||||
|
||||
if (Status.isError()) {
|
||||
// If we've already got errors, don't emit missing RightK diagnostics.
|
||||
RightLoc =
|
||||
Tok.is(RightK) ? consumeToken() : getLocForMissingMatchingToken();
|
||||
if (Tok.is(RightK)) {
|
||||
RightLoc = consumeToken();
|
||||
// Don't propagate the error because we have recovered.
|
||||
if (!Status.hasCodeCompletion())
|
||||
Status = makeParserSuccess();
|
||||
} else {
|
||||
RightLoc = getLocForMissingMatchingToken();
|
||||
}
|
||||
} else if (parseMatchingToken(RightK, RightLoc, ErrorDiag, LeftLoc)) {
|
||||
Status.setIsParseError();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user