Closed ianclawson closed 1 year ago
What is the error we see?
I just updated the description with the text error and a screenshot in addition to the title for more context. 🙏
Also here's my PR solution: https://github.com/SwifterSwift/SwifterSwift/pull/1043
The error is saying which overloads of makeIterator()
are ambiguous? I'm just curious to know because the fix would be try to disambiguate this a compile time ... I guess
Any news on this?
Any news on this?
Sorry, I wasn't able to download the beta as I wanted to understand better the issue before reviewing the PR.
I'm currently out of town and can't followup at the moment, unfortunately. I don't recall which two overloads of makeIterator()
are ambiguous.
Anyone with the beta should be able to pull up the same error though, if someone wanted to look into if before I'm back next week.
Does this help?
Yes a little bit, in the sense that I guess for byte: UInt8 in self {
would disambiguate that call. Can you give that a shot and confirm if that works? If it does, change the PR to that?
I'm still not sure how that is ambiguous since the one on Disgest should be an specialization on Sequence... so that is confusing.
Yes a little bit, in the sense that I guess
for byte: UInt8 in self {
would disambiguate that call. Can you give that a shot and confirm if that works? If it does, change the PR to that? I'm still not sure how that is ambiguous since the one on Disgest should be an specialization on Sequence... so that is confusing.
Just tried it, doesn't work.
How about that for elt in self.makeIterator()
?
I just found out that this is a compiler regression bug
This is the reduced reproducer:
struct S: Sequence {
private var _storage: [UInt8] = []
func makeIterator() -> Array<UInt8>.Iterator {
_storage.makeIterator()
}
typealias Element = UInt8
class Iterator: IteratorProtocol {
func next() -> UInt8? { 0 }
typealias Element = UInt8
}
func makeIterator() -> Iterator {
Iterator()
}
}
extension S {
func f() {
for elt in self { // error: ambiguous use of 'makeIterator()'
print(elt)
}
}
}
I've already reported the bug on https://github.com/apple/swift/issues/
How about that
for elt in self.makeIterator()
? I just found out that this is a compiler regression bug
Yeah, that works.
Nice, for the reference this is the bug: https://github.com/apple/swift/issues/60958 But I guess we can have this as a work around for now =]
Nice, for the reference this is the bug: apple/swift#60958 But I guess we can have this as a work around for now =]
Created a PR for this one. https://github.com/SwifterSwift/SwifterSwift/pull/1045
Workaround changes landed! Was actually an interesting compiler bug finding Thank you @ianclawson @theedov
Not sure why a separate PR was created when my PR was already open and essentially the same solution. But I've closed it since it's now redundant. https://github.com/SwifterSwift/SwifterSwift/pull/1043
Thanks for bringing this to a close.
Describe the bug The package will fail to build and install when used inside a project being compiled on Xcode 14 beta, with an
ambiguous use of 'makeIterator()'
error.To Reproduce
Expected behavior The SwifterSwift package will not fail to build when using Xcode 14 beta.
Additional context
Here's a screenshot of the error:
I'm about to open a PR which addresses this issue!