mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Parse] Disallow space between attribute name and '(' in Swift 6 mode
This allows us to resolve disambiguities of whether a parenthesis belong to an argument to the attribute or if it is eg. the start of a tuple.
This commit is contained in:
@@ -1514,6 +1514,9 @@ ERROR(decl_attribute_applied_to_type,none,
|
||||
ERROR(attr_extra_whitespace_after_at,PointsToFirstBadToken,
|
||||
"extraneous whitespace between '@' and attribute name", ())
|
||||
|
||||
ERROR(attr_extra_whitespace_before_lparen,PointsToFirstBadToken,
|
||||
"extraneous whitespace between attribute name and '('", ())
|
||||
|
||||
ERROR(attr_expected_lparen,none,
|
||||
"expected '(' in '%0' %select{attribute|modifier}1", (StringRef, bool))
|
||||
|
||||
|
||||
@@ -602,6 +602,18 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Consume a '('. If it is not directly following the previous token, emit an
|
||||
/// error (Swift 6) or warning (Swift <6) that attribute name and parentheses
|
||||
/// must not be separated by a space.
|
||||
SourceLoc consumeAttributeLParen();
|
||||
|
||||
/// If the next token is a '(' that's not on a new line consume it, and error
|
||||
/// (Swift 6) or warn (Swift <6) that the attribute must not be separted from
|
||||
/// the '(' by a space.
|
||||
///
|
||||
/// If the next token is not '(' or it's on a new line, return false.
|
||||
bool consumeIfAttributeLParen();
|
||||
|
||||
bool consumeIfNotAtStartOfLine(tok K) {
|
||||
if (Tok.isAtStartOfLine()) return false;
|
||||
return consumeIf(K);
|
||||
|
||||
Reference in New Issue
Block a user