Details
-
Type:
Bug
-
Status: Resolved
-
Priority:
Medium
-
Resolution: Done
-
Component/s: Compiler
-
Labels:
-
Environment:
Xcode Version 10.0 (10A255)
-
Radar URL:
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.
Attachments
Issue Links
- relates to
-
SR-8546 Enforce @escaping for for all but the most trivial uses of captured variables.
-
- Resolved
-