-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Swift 6 runtime/Compile Crash with AsyncIteratorProcotol TypedThrow #74292
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
crash
Bug: A crash, i.e., an abnormal termination of software
typed throws
Feature → error handling → throws & rethrows: Typed throws
Comments
pbk20191
added
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
crash
Bug: A crash, i.e., an abnormal termination of software
triage needed
This issue needs more specific labels
labels
Jun 11, 2024
pbk20191
changed the title
Swift 6 runtime Crash with AsyncIteratorProcotol
Swift 6 runtime/Compile Crash with AsyncIteratorProcotol TypedThrow
Jun 12, 2024
There is compile time crash with rethrow Protocol and TypedFailure. This happens in Xcode 16.0 beta swift 6 public protocol TypedAsyncIteratorProtocol<Element, Failure> {
associatedtype Element
associatedtype Failure: Error
typealias TetraFailure = Failure
@inlinable
mutating func next(isolation actor: isolated (any Actor)?) async throws(Failure) -> Element?
}
extension AsyncMapSequence.Iterator: TypedAsyncIteratorProtocol where Base.AsyncIterator: TypedAsyncIteratorProtocol {
@_implements(TypedAsyncIteratorProtocol, next(isolation:))
mutating public func tetraNext(isolation actor: isolated (any Actor)?) async throws(Base.AsyncIterator.TetraFailure) -> Self.Element? {
if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
return try await nextValue(isolation: actor)
} else {
return try await nextMapValue()
}
}
}
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension AsyncIteratorProtocol {
@usableFromInline
mutating internal func nextValue(isolation actor: isolated (any Actor)?) async throws(Failure) -> Self.Element? {
try await next(isolation: actor)
}
}
extension AsyncMapSequence.Iterator {
mutating func nextMapValue() async rethrows -> sending Self.Element? {
try await next()
}
}
This is the stack trace
|
hborla
added
typed throws
Feature → error handling → throws & rethrows: Typed throws
and removed
triage needed
This issue needs more specific labels
labels
Jul 14, 2024
Not sure if this is another incarnation of the same issue, or a related-but-different one, but it's also possible to skirt the availability checks more directly: protocol HasAsyncSequenceTraits {
associatedtype Base: AsyncSequence
associatedtype Failure
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
associatedtype _Witness = Never where Base.Failure == Failure
}
enum AsyncSequenceTraits<Base: AsyncSequence>: HasAsyncSequenceTraits {}
typealias FailureOf<S: AsyncSequence> = AsyncSequenceTraits<S>.Failure
// absurd: would allow you to "extract" the Failure associatedtype at runtime
// despite that info not being present in ABI
func extractFailureType(of sequence: any AsyncSequence) -> Error.Type {
func helper<S: AsyncSequence>(_ sequence: S) -> Error.Type {
FailureOf<S>.self
}
return helper(sequence)
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
crash
Bug: A crash, i.e., an abnormal termination of software
typed throws
Feature → error handling → throws & rethrows: Typed throws
Description
AsyncIteratorProtocol has inconsistence behavior with protocol witness table. which cause Runtime crash.
Sometime
EXC_BAD_ACCESS
Reproduction
declare own AsyncIteratorProtocol
Stack dump
Expected behavior
Not crash in runtime and should run normally.
Environment
Xcode 16.0 beta swift 6
Additional information
No response
The text was updated successfully, but these errors were encountered: