-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
#if swift(...)
nested within #if canImport
tries to parse attributes
#60876
Comments
Also encountered what seems to be the same issue with Swift 5.7: #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
import CDarwinOperatingSystemStats
import Darwin
import Dispatch
#if swift(>=5.8)
@_documentation(visibility: internal)
#endif
final class OperatingSystemStatsProducer {
var nsPerMachTick: Double
var nsPerSchedulerTick: Int
let lock = NIOLock()
...
#endif (Swift 5.8 seems ok - fail here: https://swiftpackageindex.com/builds/E19A3504-F6EA-49D3-B0C3-31A7624991ED) In my case it is #if swift() nested in #if os() though, so just similar, but not identical. |
Workaround apple/swift#60876 so we can build with Swift 5.7 again
@dnadoba Apparently this was fixed a while ago. Your examples from the additional context compile fine, and the other three are rejected, which I believe to be expected, since Tested with Swift version 5.9-dev (LLVM 91080e65df791d6, Swift c1d5118). |
@AnthonyLatsis I'm not sure I follow. struct Foo {}
#if swift(>=5.99) && canImport(SomeModuleThatDoesNotExists)
extension Foo: @someUnkownAttribute {}
#endif but this doesn't: #if canImport(SomeModuleThatDoesNotExists)
struct Foo {}
#if swift(>=5.99)
extension Foo: @someUnkownAttribute {} // error: Expected type
#endif
#endif The only difference is that we are nesting the Even if it isn't valid syntax, shouldn't it be consistently rejected? |
Ah, sorry, |
rdar://108138906 |
Describe the bug
This does not compile:
But this compiles just fine
as well as this:
Steps To Reproduce
try to compile the above code
Expected behavior
All variations compile without errors
Environment (please fill out the following information)
swiftlang/swift:nightly-main-focal
Additional context
Original issue found in the Swift 5.4 compiler with a code snipped similar to this:
We now use this workaround which compiles just fine with Swift 5.4:
The text was updated successfully, but these errors were encountered: