Description
Description
The reproduction case compiles just fine if you try a normal build:
> swiftc variadic_opaque.swift -O
>
Boring, I know. No warnings, errors, nothing. Now let's enable library evolution:
> swiftc variadic_opaque.swift -O -enable-library-evolution
>
Also uneventful. Okay, now let's emit the module interface (we need to be in library evolution mode for this):
> swiftc variadic_opaque.swift -O -enable-library-evolution -emit-module-interface-path ./some_path
>
error: verify-emitted-module-interface command failed with exit code 1 (use -v to see invocation)
variadic_opaque_interface:13:104: error: pack expansion 'repeat each T' can only appear in a function parameter list, tuple element, or generic argument of a variadic type
11 |
12 | public typealias Element = Swift.Int
13 | public typealias Iterator = @_opaqueReturnTypeOf("$s15variadic_opaque3FooV12makeIteratorQryF", 0) __<repeat each T>
| `- error: pack expansion 'repeat each T' can only appear in a function parameter list, tuple element, or generic argument of a variadic type
14 | }
15 |
variadic_opaque_interface:9:15: error: type 'Foo<repeat each T>' does not conform to protocol 'Sequence'
7 | import _StringProcessing
8 | import _SwiftConcurrencyShims
9 | public struct Foo<each T> : Swift.Sequence {
| |- error: type 'Foo<repeat each T>' does not conform to protocol 'Sequence'
| `- note: add stubs for conformance
10 | public func makeIterator() -> some Swift.IteratorProtocol<Swift.Int>
11 |
Swift.Sequence.Iterator:2:16: note: protocol requires nested type 'Iterator'
1 | protocol Sequence {
2 | associatedtype Iterator : IteratorProtocol}
| `- note: protocol requires nested type 'Iterator'
3 |
variadic_opaque_interface:10:15: error: expected '{' in body of function declaration
8 | import _SwiftConcurrencyShims
9 | public struct Foo<each T> : Swift.Sequence {
10 | public func makeIterator() -> some Swift.IteratorProtocol<Swift.Int>
| `- error: expected '{' in body of function declaration
11 |
12 | public typealias Element = Swift.Int
variadic_opaque_interface:1:1: error: failed to verify module interface of 'variadic_opaque' due to the errors above; the textual interface may be broken by project issues or a compiler bug
1 | // swift-interface-format-version: 1.0
| `- error: failed to verify module interface of 'variadic_opaque' due to the errors above; the textual interface may be broken by project issues or a compiler bug
2 | // swift-compiler-version: Apple Swift version 6.1 effective-5.10 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
3 | // swift-module-flags: -target arm64-apple-macosx15.0 -enable-objc-interop -enable-library-evolution -O -module-name variadic_opaque
Seems like it's doing something weird with the iterator typealias, leaving a dangling <repeat each T>
on the end:
public typealias Iterator = @_opaqueReturnTypeOf("$s15variadic_opaque3FooV12makeIteratorQryF", 0) __<repeat each T>
When building an XCFramework including a different type that exposed this bug, I found I was able to entirely build Xcode archives of my projects and package them in to a framework without this module verifier running (doesn't seem to be on by default, it seems), but clients were unable to import the resulting framework.
Reproduction
public struct Foo<each T>: Sequence {
var pack: (repeat each T)
public func makeIterator() -> some IteratorProtocol<Int> {
MyIter(pack: (repeat each pack))
}
}
internal struct MyIter<each T>: IteratorProtocol {
var pack: (repeat each T)
mutating func next() -> Int? { 0 }
}
Expected behavior
Expect this code to produce a valid module interface that can be read by other compilers.
Environment
swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0
Additional information
No response