-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itself
Description
Previous ID | SR-11778 |
Radar | rdar://problem/56998726 |
Original Reporter | @xedin |
Type | Bug |
Status | Resolved |
Resolution | Done |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | @hamishknight |
Priority | Medium |
md5: db8faab81e6ef687c92bbc71a7ec459b
Issue Description:
Default argument values are not respected when using the newly added callAsFunction/static callable feature of Swift 5.1. See example playground. I would expect the code to execute without an error, but instead the compiler wants me to provide a value for “completion:” even though I define a default value in the callAsFunction method.
struct DoubleANumber {
func callAsFunction(_ x: Int, completion: (Int) -> Void = { _ in }) {
completion(x + x)
}
}
let x = DoubleANumber()
x(3)
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itself