Description
Previous ID | SR-2989 |
Radar | rdar://28883410 |
Original Reporter | rosslebeau (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Won't Do |
Environment
Swift 3.0
macOS 10.12 16A323
Additional Detail from JIRA
Votes | 1 |
Component/s | LLDB for Swift |
Labels | Bug |
Assignee | @vedantk |
Priority | Medium |
md5: b5bc35bd9978fec0d64c651b37689c3f
Issue 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