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-5105] inconsistent index of Data #3850

Closed
SusanDoggie opened this issue Jun 6, 2017 · 1 comment
Closed

[SR-5105] inconsistent index of Data #3850

SusanDoggie opened this issue Jun 6, 2017 · 1 comment

Comments

@SusanDoggie
Copy link

Previous ID SR-5105
Radar None
Original Reporter @SusanDoggie
Type Bug

Attachment: Download

Environment

Xcode 9 Beta

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: bbb1c6ef148c3d54780fb1cd79e4cb15

relates to:

  • SR-5430 Bugs with slice of Data
  • SR-4964 Subscripting a subscripted Data offsets incorrectly
  • SR-8883 ArraySlice/Data subscript behavior is not intuitive and dangerous

Issue Description:

here are the sample

let data = Data([1, 2, 3, 4, 5, 6, 7, 8, 9])

let data2 = data.suffix(from: 2)

Array(data2)  // [5, 6, 7, 8, 9, 99, 199]
Array(data[2...])  // [5, 6, 7, 8, 9, 99, 199]

data2.indices  // CountableRange(2..<9)

data2.startIndex  // 2

data2[0] // 3
data2[2] // 5

Array(Data(data2)) // [3, 4, 5, 6, 7, 8, 9]
@belkadan
Copy link

belkadan commented Jun 7, 2017

This looks correct. Remember the requirement that slicing a Collection gives you back a new Collection that uses the same indices.

(data2[0] should probably trap, though. @phausler?)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants