swiftlang/swift
Invalid fix-it on unused optional binding when multiple conditions
開放
#89,131 建立於 2026年5月14日
compilerdiagnostics qualityfix-itsgood first issuestatementsswift 6.4type checker
倉庫指標
- 星標
- (69,989 顆星)
- PR 合併指標
- (平均合併 8天 17小時) (30 天內合併 510 個 PR)
描述
Description
No response
Reproduction
func sync() -> Int? {}
func async() async -> Int? {}
do {
if let x = sync(), true {} // bad fix-it
if let x = sync() {} // good fix-it
if let x = await async(), true {} // bad fix-it
if let x = await async() {} // good fix-it
}
warning: immutable value 'x' was never used; consider replacing with '_' or removing it [#NoUsage]
if let x = sync(), true {}
~~~~^
_
warning: value 'x' was defined but never used; consider replacing with boolean test [#NoUsage]
if let x = sync() {}
~~~~^~~~
!= nil
warning: immutable value 'x' was never used; consider replacing with '_' or removing it [#NoUsage]
if let x = await async(), true {}
~~~~^
_
warning: value 'x' was defined but never used; consider replacing with boolean test [#NoUsage]
if let x = await async() {}
~~~~^~~~
( ) != nil
Expected behavior
Fix-it should match the one we emit when the condition is single.
Environment
f0d8239caeefc8b
Additional information
Please add tests for both if let x = sync(), true and if true, let x = sync().