Merge pull request #34620 from AnthonyLatsis/parse-misc

Parse: Only diagnose dollar-prefixed identifiers that are Swift declarations
This commit is contained in:
Anthony Latsis
2020-12-04 09:09:45 +03:00
committed by GitHub
10 changed files with 119 additions and 85 deletions

View File

@@ -975,7 +975,7 @@ ParserResult<Pattern> Parser::parsePattern() {
case tok::identifier: {
PatternCtx.setCreateSyntax(SyntaxKind::IdentifierPattern);
Identifier name;
SourceLoc loc = consumeIdentifier(&name);
SourceLoc loc = consumeIdentifier(name, /*diagnoseDollarPrefix=*/true);
if (Tok.isIdentifierOrUnderscore() && !Tok.isContextualDeclKeyword())
diagnoseConsecutiveIDs(name.str(), loc,
introducer == VarDecl::Introducer::Let
@@ -1054,7 +1054,7 @@ Parser::parsePatternTupleElement() {
// If the tuple element has a label, parse it.
if (Tok.is(tok::identifier) && peekToken().is(tok::colon)) {
LabelLoc = consumeIdentifier(&Label);
LabelLoc = consumeIdentifier(Label, /*diagnoseDollarPrefix=*/true);
consumeToken(tok::colon);
}