Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Medium
-
Resolution: Won't Do
-
Component/s: LLDB for Swift
-
Labels:None
-
Environment:
Swift 3.0
macOS 10.12 16A323
-
Radar URL:
Description
In certain cases, if you have a multi-line function chain, placing a breakpoint on the first line will actually result in the function chain being evaluated before the breakpoint hits.
For example:
func printMarker(_ x: Int) -> Int { print("marker") return x } struct User { let name: String let age: Int } struct Message { func mentionedUsersF() -> [User] { return [User(name: "Achilles", age: 32), User(name: "Tortoise", age: 105)] } } let message = Message() var ages: [Int] ages = [1, 2, 3] ages = message .mentionedUsersF() .map { $0.age } .map(printMarker) print(ages)
Place a breakpoint on the `ages = message` line, and you will see that "marker" has been printed at the time of breaking. The `ages` variable is still equal to `[1, 2, 3]`, however, so it hasn't been set yet.
This also occurs if you use a computed property instead of a function.
This does not happen if:
- Any of the function calls are moved up to the first line
- The struct contains a non-computed property (it can be unused, as long as there is one)
- A class is used instead of struct
- Functions that are not members of a struct are used instead