Skip to content

Parse attributes in #if #1276

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
Jan 27, 2023
Merged

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jan 26, 2023

Fixes #1119
rdar://103048943

@ahoppen ahoppen requested a review from bnbarham January 26, 2023 09:18
@ahoppen
Copy link
Member Author

ahoppen commented Jan 26, 2023

@swift-ci Please test

@@ -207,42 +207,35 @@ extension Parser.Lookahead {
return true
}

/// Tries consuming a `#if` directive that only contains attributes.
/// Returns `true` if that was successful and `false` if
/// - we are not at a valid `#if` directive (e.g. `#elseif` is missing)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// - we are not at a valid `#if` directive (e.g. `#elseif` is missing)
/// - we are not at a valid `#if` directive (e.g. `#endif` is missing)

var didSeeAnyAttributes = false
var poundIfLoopProgress = LoopProgressCondition()
repeat {
self.consume(ifAny: [.poundIfKeyword, .poundElseKeyword, .poundEndifKeyword])
Copy link
Member

@rintaro rintaro Jan 26, 2023

Choose a reason for hiding this comment

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

You meant poundElseifKeyword?

Suggested change
self.consume(ifAny: [.poundIfKeyword, .poundElseKeyword, .poundEndifKeyword])
assert(self.at(any: [.poundIfKeyword, .poundElseifKeyword, .poundElseKeyword]))
consumeAnyToken()

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, thanks

@@ -120,6 +120,13 @@ extension TokenConsumer {
return false
}
}

mutating func atStartOfIfConfigOfAttributes() -> Bool {
Copy link
Member

Choose a reason for hiding this comment

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

Unused?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, yes. Thanks

Fixes swiftlang#1119
rdar://103048943
@ahoppen ahoppen force-pushed the ahoppen/attribute-if-config branch from b3a2458 to 0381f9c Compare January 26, 2023 22:43
@ahoppen
Copy link
Member Author

ahoppen commented Jan 26, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit a7abc29 into swiftlang:main Jan 27, 2023
@ahoppen ahoppen deleted the ahoppen/attribute-if-config branch January 27, 2023 10:04
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.

SE-0367 unimplemented
3 participants