Skip to content
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

[SR-1487] Bug in String Slice Indices or Generic Code Generator #44096

Closed
hooman opened this issue May 11, 2016 · 2 comments
Closed

[SR-1487] Bug in String Slice Indices or Generic Code Generator #44096

hooman opened this issue May 11, 2016 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself standard library Area: Standard library umbrella

Comments

@hooman
Copy link
Contributor

hooman commented May 11, 2016

Previous ID SR-1487
Radar rdar://26229877
Original Reporter @hooman
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Swift 3.0 2016-05-03 (a) snapshot on Xcode 7.3.1 on OS X 10.11.4

Additional Detail from JIRA
Votes 0
Component/s Compiler, Standard Library
Labels Bug
Assignee None
Priority Medium

md5: 19f168e35e803c8003b27ff3e4c27825

is duplicated by:

  • SR-1927 Subsequences of String Views don’t behave correctly

Issue Description:

I am not sure if it is a standard library bug or a generics code generation issue as it does not show up in non-generic version of the same code. Run this code with the latest Swift 3.0 snapshot to see the issue:

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"    
@ole
Copy link
Contributor

ole commented Oct 15, 2016

I confirmed that this is fixed in master because the fix for SR-1927 has been merged.

@hooman
Copy link
Contributor Author

hooman commented Oct 22, 2016

Thank you. I closed the related radar as well.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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. compiler The Swift compiler in itself standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants