Open
Description
Description
No response
Reproduction
struct Foo {
@available(macOS 15, *)
var bar: Int { 42 }
}
func test(_ foo: Foo) {
let x = {
if #available(macOS 15, *) {
foo.bar // 'bar' is only available in macOS 15 or newer
} else {
nil
}
}() ?? 0
}
If we remove ?? 0
, or if we add : Int
to the variable, the error is gone.
Expected behavior
Compiles
Environment
Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
Target: arm64-apple-macosx15.0
Additional information
No response