-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
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.expressionsFeature: expressionsFeature: expressionstriage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
The compiler does not emit diagnostics about irrefutable conditions in if expressions, even though it does for if statements.
Reproduction
func testStmt() -> Bool {
if case _: Int? = nil { // warning: 'if' condition is always true
return true
} else {
return false
}
}
func testExpr() -> Bool {
return if case _: Int? = nil { true } else { false } // no warning
}
Expected behavior
Both test cases should be diagnosed equivalently.
Environment
$ ../build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/bin/swiftc -version
Swift version 6.3-dev (LLVM 82c14639a1e4d89, Swift e896e0b9b7cf78f)
Target: arm64-apple-macosx26.0
Build config: +assertions
Additional information
No response
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.expressionsFeature: expressionsFeature: expressionstriage neededThis issue needs more specific labelsThis issue needs more specific labels