-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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 itselftype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
| Previous ID | SR-8546 |
| Radar | rdar://problem/43355341 |
| Original Reporter | @atrick |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Attachment: Download
Additional Detail from JIRA
| Votes | 1 |
| Component/s | Compiler |
| Labels | Bug, TypeChecker |
| Assignee | @slavapestov |
| Priority | Medium |
md5: 5633bcbc0929418f15d8bc331f63f2ed
relates to:
- SR-9043 Missing checks of inout/mutating captures
Issue Description:
This is a source compatibility bug.
A nested function used in an @escaping context must produce a type
checker error. In the example below, we expect a diagnostic:
error: nested function with an implicitly captured inout parameter can only be used as a non-escaping argumentInstead we get an error in diagnose exclusivity, but only in asserts builds, which is not good enough to protect against undefined behavior.
Applied argument must be @noescape function type: %21 = argument of bb3 : $@callee_guaranteed () -> ()
A partial_apply with @inout_aliasable may only be used as a @noescape function type argument.
UNREACHABLE executed at /s/s/swift/lib/SILOptimizer/Mandatory/DiagnoseStaticExclusivity.cpp:1085!func doit(_ f: @escaping ()->()) { f() }
public func outerFoo1(x: inout Int) {
func innerFoo1() {
x = 1
}
func innerFoo2() {
x = 2
}
doit(x == 0 ? innerFoo1 : innerFoo2)
}Reactions are currently unavailable
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 itselftype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis