hooman
(Hooman Mehr)
1
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
gribozavr
(Dmitri Gribenko)
2
Hi Hooman,
This is a bug in String indices. Could you file it, we will look into it.
Dmitri
···
On Wed, May 11, 2016 at 1:48 PM, Hooman Mehr via swift-users <swift-users@swift.org> wrote:
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 for the initial discussion that lead to
this.
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/
hooman
(Hooman Mehr)
3
Filed as: SR-1487 <Issues · apple/swift-issues · GitHub;
···
On May 11, 2016, at 1:51 PM, Dmitri Gribenko <gribozavr@gmail.com> wrote:
On Wed, May 11, 2016 at 1:48 PM, Hooman Mehr via swift-users > <swift-users@swift.org> wrote:
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 for the initial discussion that lead to
this.
Hi Hooman,
This is a bug in String indices. Could you file it, we will look into it.
Dmitri
--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr@gmail.com>*/