-
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 itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
| Previous ID | SR-9043 |
| Radar | rdar://problem/45511834 |
| Original Reporter | koher (JIRA User) |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Environment
Xcode Version 10.0 (10A255)
Additional Detail from JIRA
| Votes | 1 |
| Component/s | Compiler |
| Labels | Bug, CompilerCrash, TypeChecker |
| Assignee | @slavapestov |
| Priority | Medium |
md5: 23f0e6aa3983c486dcd3930dc0b1232d
relates to:
Issue Description:
The following code causes a compile-time error correctly.
func run(_ body: @escaping () -> Void) { body() }
struct S {
var a: Int = 3
mutating func foo() {
func _foo() {
if a == 0 { return }
a -= 1
print(a)
run(_foo)
}
_foo()
}
}
var s = S()
s.foo()error: nested function with an implicitly captured inout parameter can only be used as a non-escaping argument
run(_foo)
^However, when `run(_foo)` is changed to `run { _foo() }`, it can be compiled. I guess the compiler lacks some checks.
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 itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis