Skip to content

[Parse] Ignore '(' on newline after attribute names #83497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Aug 1, 2025

Also '#error', '#warning', and '#sourceLocation'.

Other call-like syntax (call expression, macro expansion, custom attributes, and some builtin attributes like @available) requires '(' on the same line as the callee name. For consistency, all built-in attributes and directives should also ignore '(' on next line.

@rintaro
Copy link
Member Author

rintaro commented Aug 1, 2025

swiftlang/swift-syntax#3132
@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Aug 1, 2025

swiftlang/swift-syntax#3132
@swift-ci Please Test Source Compatibility

@@ -2503,7 +2503,7 @@ static std::optional<Identifier> parseSingleAttrOptionImpl(
};
bool isDeclModifier = DeclAttribute::isDeclModifier(DK);

if (!P.Tok.is(tok::l_paren)) {
if (!P.Tok.isFollowingLParen()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this change but I've always disliked the name isFollowingLParen, to me it reads as "is token following an l-paren", when really it's "is token a following-l-paren". Maybe we should just call it isSameLineLParen?

Also '#error', '#warning', and '#sourceLocation'.

Other call-like syntax (call expression, macro expansion, and custom
attribtues) requires '(' on the same line as the callee. For consistency,
built-in attributes and built-in directives should also ignore '(' on
next line.
@rintaro rintaro force-pushed the parse-attr-l-paren-newline branch from 44ecb58 to b271766 Compare August 4, 2025 15:39
@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please Test Source Compatibility

1 similar comment
@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please Test Source Compatibility

@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please smoke test Linux

@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please smoke test macOS

@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please Test Source Compatibility Release

2 similar comments
@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please Test Source Compatibility Release

@rintaro
Copy link
Member Author

rintaro commented Aug 4, 2025

swiftlang/swift-syntax#3132
@swift-ci Please Test Source Compatibility Release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants