-
Notifications
You must be signed in to change notification settings - Fork 440
Assert that tokens in the syntax tree match token_choices
and text_choices
#1180
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
Conversation
token_choices
and text_choices
🚥 #1173token_choices
and text_choices
897e9b7
to
3f64e22
Compare
token_choices
and text_choices
token_choices
and text_choices
🚥 #1289
@@ -8531,6 +8680,7 @@ public struct RawAccessorDeclSyntax: RawDeclSyntaxNodeProtocol { | |||
_ unexpectedAfterBody: RawUnexpectedNodesSyntax? = nil, | |||
arena: __shared SyntaxArena | |||
) { | |||
assert(accessorKind.tokenKind == .keyword(.get) || accessorKind.tokenKind == .keyword(.set) || accessorKind.tokenKind == .keyword(.didSet) || accessorKind.tokenKind == .keyword(.willSet) || accessorKind.tokenKind == .keyword(.unsafeAddress) || accessorKind.tokenKind == .keyword(.addressWithOwner) || accessorKind.tokenKind == .keyword(.addressWithNativeOwner) || accessorKind.tokenKind == .keyword(.unsafeMutableAddress) || accessorKind.tokenKind == .keyword(.mutableAddressWithOwner) || accessorKind.tokenKind == .keyword(.mutableAddressWithNativeOwner) || accessorKind.tokenKind == .keyword(._read) || accessorKind.tokenKind == .keyword(._modify), "Received \(accessorKind.tokenKind)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should overlap with the subset right? Wonder if we should autogenerate subsets when there's > 1 kind. I imagine that would be a lot though, maybe only > 3 and then at
can have overloads for up to 3 kinds or a subset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s the next item on my To-Do list after this PR is merge: “Generate RawTokenKindSubset”. I’m still not entirely sure how exactly we want to decide whether to generate the RawTokenKindSubset
, but it’s definitely something we should do.
@_dynamicReplacement(for: <#identifier#>) | ||
@_dynamicReplacement(for : <#identifier#>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the whitespace for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I wanted to fix that. It’s because for
is a keyword now and keywords always have trailing space in BasicFormat at the moment. Improving that is a slightly larger change in BasicFormat that I would like to do in a follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we go: #1298
3f64e22
to
d581360
Compare
…oices Previously, we specified text_choices and token_chocies in the Python files but we weren’t actually verifying that the tokens we pass into the syntax tree match these expectations. Add assertions that check the token kinds. rdar://103448567
d581360
to
1cde192
Compare
token_choices
and text_choices
🚥 #1289token_choices
and text_choices
@swift-ci Please test |
We currently specify
token_choices
andtext_choices
in the Python files but don't enforce that the tokens in the syntax tree actually match these – effectively we are ignoring these properties.Add assertions that the actual tokens in the syntax tree match the specification and fix a few cases where these assertions were violated.
rdar://103448567