[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:
Nathan Hawes
2020-03-04 15:14:18 -08:00
parent a368434432
commit 1c729ca3e1
4 changed files with 44 additions and 35 deletions

View File

@@ -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();
}