Skip to content

add parsing for ~ (the 'without' operator) #1461

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

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

kavon
Copy link
Member

@kavon kavon commented Mar 28, 2023

see the primary PR swiftlang/swift#64699 for more details. This companion PR implements the parsing for the "without operator" ~ used for conformance suppression. For example, ~Copyable.

rdar://106775103

@kavon kavon requested a review from ahoppen as a code owner March 28, 2023 22:16
@kavon
Copy link
Member Author

kavon commented Mar 28, 2023

@swift-ci please test

Comment on lines +1556 to +1562
assertParse(
"""
struct Hello: ~Copyable {}

enum Whatever: Int, ~ Hashable, Equatable {}
"""
)
Copy link
Member

Choose a reason for hiding this comment

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

Could you create separate assertParse checks for these two cases and make sure they are parsed correctly (i.e. actually have the ~ as a separate token that’s not part of the identifier?

Comment on lines +232 to +234
if self.currentToken.starts(with: "~") {
withoutToken = self.consumePrefix("~", as: .prefixOperator)
}
Copy link
Member

Choose a reason for hiding this comment

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

Is the ~ part of the identifier? If so, that would surprise me. I would assume that you should be able to do

withoutToken = self.consumeIfContextualPunctuator("~")

/// indicate the suppression of implicit conformance to this type.
/// This child stores the token representing the 'without' operator.
Child(
name: "HasWithout",
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer this to be named WithoutTilde. This actually contains the tilde itself, so it’s not a boolean variable, which the Has implies.

ahoppen pushed a commit to ahoppen/swift-syntax that referenced this pull request Apr 18, 2023
add parsing for ~ (the 'without' operator)
@kavon
Copy link
Member Author

kavon commented Apr 19, 2023

thanks alex for the review. i've addressed them in #1559

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