Playground iterates forever
Originator: | apontious | ||
Number: | rdar://30018517 | Date Originated: | 1/13/2017 |
Status: | Closed | Resolved: | 8/18/2018 |
Product: | Swift Playgrounds | Product Version: | 8.2.1 |
Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary: Use of a temporary variable in a class's description computed property seems to make Playgrounds go wild, iterating forever. Steps to Reproduce: 1. Download attached LinkedList.playground 2. Open it in Xcode 8.2.1 on El Capitan 3. Watch it run 4. Uncomment the "This iterates forever" code that is currently commented out, and comment out the "This works" code. Expected Results: Description should be executed just as before since the two code blocks are functionally identical. Actual Results: Playground starts iterating forever. Version: Xcode 8.2.1 Notes: Configuration: El Capitan 10.11.6 with latest updates. Playground contents follow: //: Playground - noun: a place where people can play class LinkedList: CustomStringConvertible { var next: LinkedList? let data: Int init(next: LinkedList?, data: Int) { self.next = next self.data = data } var description: String { var result = "\(data)" // This works if next != nil { result += ", \(next!.data)" } // This iterates forever /*let i: LinkedList? = next if i != nil { result += ", \(i!.data)" }*/ return result } } func linkedListFromArray(_ array: [Int]) -> LinkedList? { var head, tail: LinkedList? for data in array { let temp = LinkedList(next: nil, data: data) if head == nil { head = temp } tail?.next = temp tail = temp } return head } let linkedList1 = linkedListFromArray([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) let linkedList2 = linkedListFromArray([]) let linkedList3 = linkedListFromArray([1])
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Seems to work now in Xcode 9.4.1