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-11555] popFirst() requires the types '[Int]' and 'ArraySlice<Int>' be equivalent #53956

Open
krzyzanowskim opened this issue Oct 1, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@krzyzanowskim
Copy link
Contributor

Previous ID SR-11555
Radar None
Original Reporter @krzyzanowskim
Type Bug
Environment

Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)

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

md5: f317b6bcacb696f4a627908e32beb39a

Issue Description:

var arr = [1,2,3]

//  error: referencing instance method 'popFirst()' on 'Collection' requires the types '[Int]' and 'ArraySlice<Int>' be equivalent
arr.popFirst() 

It should works just like `popLast()` works

@belkadan
Copy link
Contributor

belkadan commented Oct 1, 2019

Yeah, why is this one called removeFirst and popFirst is something else? @milseman and @lorentey might know.

@milseman
Copy link
Mannequin

milseman mannequin commented Oct 1, 2019

`popFirst()` and `popLast()` are only available for Collections that are their own slice types, hence that error message.

`extension [Bidirectional]Collection where SubSequence == Self { ... }`

edit: RangeReplaceableCollection does provide an implementation of `popLast()` though, but not `popFirst()`. It claims O(1), which `popFirst()` wouldn't be able to provide generally.

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

No branches or pull requests

2 participants