Merge pull request #24059 from sl/sl/sr-10293

Allow var / let as parameter names but provide a warning and fixit to add backticks.
This commit is contained in:
Sam Lazarus
2019-04-26 09:30:23 -04:00
committed by GitHub
15 changed files with 139 additions and 76 deletions

View File

@@ -852,10 +852,9 @@ ERROR(parameter_specifier_as_attr_disallowed,none,
"'%0' before a parameter name is not allowed, place it before the parameter type instead",
(StringRef))
ERROR(parameter_specifier_repeated,none,
"parameter must not have multiple '__owned', 'inout', '__shared',"
" 'var', or 'let' specifiers", ())
ERROR(parameter_let_var_as_attr,none,
"'%0' as a parameter attribute is not allowed",
"parameter must not have multiple '__owned', 'inout', or '__shared' specifiers", ())
WARNING(parameter_let_var_as_attr,none,
"'%0' in this position is interpreted as an argument label",
(StringRef))

View File

@@ -609,6 +609,8 @@ public:
void skipUntilDeclRBrace(tok T1, tok T2);
void skipListUntilDeclRBrace(SourceLoc startLoc, tok T1, tok T2);
/// Skip a single token, but match parentheses, braces, and square brackets.
///
/// Note: this does \em not match angle brackets ("<" and ">")! These are

View File

@@ -173,8 +173,8 @@ public:
return true;
}
// 'let', 'var', and 'inout' cannot be argument labels.
if (isAny(tok::kw_let, tok::kw_var, tok::kw_inout))
// inout cannot be used as an argument label.
if (is(tok::kw_inout))
return false;
// All other keywords can be argument labels.