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-1595] Chained subsequence operations confuse the compiler #44204

Closed
natecook1000 opened this issue May 23, 2016 · 1 comment
Closed

[SR-1595] Chained subsequence operations confuse the compiler #44204

natecook1000 opened this issue May 23, 2016 · 1 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 type checker Area → compiler: Semantic analysis

Comments

@natecook1000
Copy link
Member

Previous ID SR-1595
Radar None
Original Reporter @natecook1000
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler, Standard Library
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 1622ec52e01ecd9f6cd4ebb2fe338b4c

duplicates:

  • SR-851 Result of dropFirst differs between 2.1.1 and 2.2

Issue Description:

If I chain collection operations that produce subsequences, the compiler finds ambiguous ways of resolving the methods.

(swift) let x = Array(1...10)
// x : Array<Int> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
(swift) x.dropFirst(2).prefix(5)
<REPL Input>:1:1: error: ambiguous use of 'dropFirst'
x.dropFirst(2).prefix(5)
^
Swift.Collection:39:17: note: found this candidate
    public func dropFirst(_ n: Int) -> Self.SubSequence
                ^
Swift.Sequence:20:17: note: found this candidate
    public func dropFirst(_ n: Int) -> AnySequence<Self.Iterator.Element>
                ^

If I break the calls up into separate assignments, there's no such trouble.

(swift) let y = x.dropFirst(2)
// y : ArraySlice<Int> = ArraySlice([3, 4, 5, 6, 7, 8, 9, 10])
(swift) y.prefix(5)
// r0 : ArraySlice<Int> = ArraySlice([3, 4, 5, 6, 7])
@moiseev
Copy link
Mannequin

moiseev mannequin commented May 24, 2016

Duplicate of https://bugs.swift.org/browse/SR-851

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

1 participant