@@ -3002,15 +3002,25 @@ Parser::parseDecl(ParseDeclOptions Flags,
3002
3002
// Must not confuse it with trailing closure syntax, so we only
3003
3003
// recover in contexts where there can be no statements.
3004
3004
3005
- if ((Tok.isIdentifierOrUnderscore () &&
3006
- peekToken ().isAny (tok::colon, tok::equal, tok::comma)) ||
3007
- Tok.is (tok::l_paren)) {
3005
+ const bool IsProbablyVarDecl =
3006
+ Tok.isIdentifierOrUnderscore () &&
3007
+ peekToken ().isAny (tok::colon, tok::equal, tok::comma);
3008
+
3009
+ const bool IsProbablyTupleDecl =
3010
+ Tok.is (tok::l_paren) && peekToken ().isIdentifierOrUnderscore ();
3011
+
3012
+ if (IsProbablyVarDecl || IsProbablyTupleDecl) {
3008
3013
diagnose (Tok.getLoc (), diag::expected_keyword_in_decl, " var" ,
3009
3014
" property" )
3010
3015
.fixItInsert (Tok.getLoc (), " var " );
3011
3016
parseLetOrVar (/* HasLetOrVarKeyword=*/ false );
3012
3017
break ;
3013
- } else if (Tok.isIdentifierOrUnderscore () || Tok.isAnyOperator ()) {
3018
+ }
3019
+
3020
+ const bool IsProbablyFuncDecl =
3021
+ Tok.isIdentifierOrUnderscore () || Tok.isAnyOperator ();
3022
+
3023
+ if (IsProbablyFuncDecl) {
3014
3024
diagnose (Tok.getLoc (), diag::expected_keyword_in_decl, " func" ,
3015
3025
" function" )
3016
3026
.fixItInsert (Tok.getLoc (), " func " );
0 commit comments