-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
#availableFeature → statements: Availability conditionFeature → statements: Availability conditionbugA 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 itselfswift 6.1swift 6.2
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
Metadata
Metadata
Assignees
Labels
#availableFeature → statements: Availability conditionFeature → statements: Availability conditionbugA 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 itselfswift 6.1swift 6.2