The reason this is appearing here before filing a radar is getting a quick
feedback as I have been assuming this is the expected behavior but Nate Cook
told me otherwise. See this thread
<https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160509/017048.html>
for the initial discussion that lead to this.
Run this code to see the issue: (Works with the latest Swift 3.0 snapshot)
func subSequenceIndexBug
<C: Collection
where
C.Iterator.Element: Equatable,
C.SubSequence: Collection,
C.SubSequence.Index == C.Index,
C.SubSequence.Iterator.Element == C.Iterator.Element>
(_ c: C, _ e: C.Iterator.Element)
{
let junction = c.index(c.startIndex, offsetBy: numericCast(5)) //
Arbitrary split point.
if let i = c.suffix(from: junction).index(of: e) {
print("Searched for \"\(e)\" and found \"\(c[i])\". Result of
testing them for equality is: \(e == c[i])")
}
}
subSequenceIndexBug("ABCDEFGHIJKLMNOPQRSTUVWXYZ".characters, "Q")
// Prints: "Searched for "Q" and found "L". Result of testing them for
equality is: false"
Is this a generics design limitation, my bug, or a compiler bug?
Thanks for your,
Hooman
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users