Avatar
Avatar
kebo
@swift-6.2.1 -warnings-as-errors @swift-6.2.1 -warnings-as-errors -swift-version 6 func f<T>(_ closure: () -> T) -> T { closure() } final class C { let a = 0 init() { f { [weak self] in guard let self else { return } f { [self] in print(a) } } } }
swift -warnings-as-errors - exit status 1 with stderr:<stdin>:11:23: error: reference to property 'a' in closure requires explicit use of 'self' to make capture semantics explicit; this is an error in the Swift 6 language mode 9 | guard let self else { return } 10 | f { [self] in 11 | print(a) | `- error: reference to property 'a' in closure requires explicit use of 'self' to make capture semantics explicit; this is an error in the Swift 6 language mode 12 | } 13 | } <stdin>:10:18: error: capture 'self' was never used [#no-usage] 8 | f { [weak self] in 9 | guard let self else { return } 10 | f { [self] in | `- error: capture 'self' was never used [#no-usage] 11 | print(a) 12 | }