You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
I looked into this recently and found that there isn't a good way to address this problem.
Any fix that enables stepping on the line "ages = message" prior to a call to map would result in inconsistent stepping behavior between Swift and C-based languages. Further, it might result in spurious extra stepping onto lines which just contain a reference to a decl.
Environment
Swift 3.0
macOS 10.12 16A323
Additional Detail from JIRA
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:
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
The text was updated successfully, but these errors were encountered: