mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Parse / AST: Allow let / var as argument labels with a warning.
The diagnostic is now a warning and the new message alerts the user that though it is valid to have let and var as argument label names, they are interpreted as argument labels, not keywords.
This commit is contained in:
@@ -854,8 +854,8 @@ ERROR(parameter_specifier_as_attr_disallowed,none,
|
||||
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",
|
||||
WARNING(parameter_let_var_as_attr,none,
|
||||
"'%0' in this position is interpreted as an argument label",
|
||||
(StringRef))
|
||||
|
||||
|
||||
|
||||
@@ -587,6 +587,8 @@ public:
|
||||
|
||||
void skipUntilDeclRBrace(tok T1, tok T2);
|
||||
|
||||
void skipListUntilDeclRBrace(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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user