-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
Incorrect optional inference on trunk #80494
Comments
Smaller reproducer: extension AsyncStream {
public static var finished: Self { fatalError() }
}
extension Int {
public func stream() -> AsyncStream<Int> { fatalError() }
}
extension Optional<Int> {
func fetch() async throws {
for await i in self?.stream() ?? .finished {
print(i)
}
}
} EDIT: Even smaller: extension AsyncStream {
public static var finished: Self { fatalError() }
}
nonisolated var defaultStream: AsyncStream<Int> { fatalError() }
func fetch() async throws {
for await i in (defaultStream ?? .finished) {}
} Godbolt link: https://godbolt.org/z/7dGnhE9dj |
Problem occurs even with a custom operator:
with this case, the error is:
So it appears something changed with how the types are getting inferred for the generic args here. cc @xedin |
For some reason on
|
Ah, potentially already fixed by #80443 ! |
I would like to leave this open to confirm that #80443 fixes the issue for us. |
I can confirm that #80443 fixed the issue. Closing. |
Description
Code that used to compile with older compiler versions fails to compile with a compiler built from trunk. This seems to be due to some incorrect type inferrence.
Reproduction
Expected behavior
The above code compiles. It compiles fine with Swift 6.0.3.
Environment
Additional information
Error message:
The text was updated successfully, but these errors were encountered: