Open
Description
Describe the bug
This does not compile:
#if canImport(SomeModuleThatDoesNotExists)
struct Foo {}
#if swift(>=5.99)
extension Foo: @someUnkownAttribute {} // error: Expected type
#endif
#endif
But this compiles just fine
struct Foo {}
#if swift(>=5.99)
extension Foo: @someUnkownAttribute {}
#endif
as well as this:
struct Foo {}
#if swift(>=5.99) && canImport(SomeModuleThatDoesNotExists)
extension Foo: @someUnkownAttribute {}
#endif
Steps To Reproduce
try to compile the above code
Expected behavior
All variations compile without errors
Environment (please fill out the following information)
- OS: 13.0 Beta (22A5331e)
- Xcode Version 14.0 beta 6 (14A5294g) but with Toolchain: Swift Development Snapshot 2022-08-18 (a)
- also tested in docker with
swiftlang/swift:nightly-main-focal
Additional context
Original issue found in the Swift 5.4 compiler with a code snipped similar to this:
#if canImport(Network)
class Foo {}
#if swift(>=5.5) && canImport(_Concurrency)
extension Foo: @unchecked Sendable {} // error: unknown attribute 'unchecked'
#endif
#endif
We now use this workaround which compiles just fine with Swift 5.4:
#if canImport(Network)
class Foo {}
#endif
#if swift(>=5.5) && canImport(_Concurrency) && canImport(Network)
extension Foo: @unchecked Sendable {}
#endif
Metadata
Metadata
Assignees
Labels
Feature → compiler control statements: Conditional compilation blocksFeature: Declaration and type attributesA deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfFeature: compiler control statementsArea → compiler: The legacy C++ parserBug: Unexpected error