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-9787] Source code incompatibility in Swift compiler 5.0, language 4.2 #52212

Closed
tonyarnold opened this issue Jan 29, 2019 · 4 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. regression standard library Area: Standard library umbrella swift 5.0

Comments

@tonyarnold
Copy link
Contributor

Previous ID SR-9787
Radar None
Original Reporter @tonyarnold
Type Bug
Status Resolved
Resolution Won't Do
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, 5.0Regression
Assignee None
Priority Medium

md5: d0f3d0ff87f6655b49ad49acfb679737

Issue Description:

The following code compiles fine under Swift 4.2 with compiler version 4.2:

class Node {
    weak private(set) var parent: Node?

    init(parent: Node? = nil) {
        self.parent = parent
    }

    var parentNodes: AnySequence<Node> {
        return sequence(first: self, next: { $0.parent }).dropFirst()
    }
}

However under Swift 4.2 language mode with the 5.0 compiler, I get the following error:

Cannot convert return expression of type 'DropFirstSequence<UnfoldSequence<Node, (Node?, Bool)>>' to return type 'AnySequence<Node>'
@belkadan
Copy link
Contributor

@airspeedswift, @lorentey, do we have a story for people who were using AnySequence in this way?

@belkadan
Copy link
Contributor

belkadan commented Apr 2, 2019

Circling back: I think the core team decided this was necessary breakage. @airspeedswift?

@airspeedswift
Copy link
Member

Yes, that's right. The Sequence.SubSequence removal wan't something that could easily be made source-compatibly but was important to get the ABI for Sequence right. Advice is either wrap the return value or change it to the new type.

@airspeedswift
Copy link
Member

(as a apology-benefit, the old variant using AnySequence was epically slow compared to using DropFirstSequence if that's the fix you pick...

@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. regression standard library Area: Standard library umbrella swift 5.0
Projects
None yet
Development

No branches or pull requests

4 participants