Open
Description
Description
No response
Reproduction
struct S {
var discardableGetter: Int {
@discardableResult
get {
return 0
}
}
}
func test() {
S().discardableGetter
}
../discardableGetter.swift:11:9: warning: expression of type 'Int' is unused
9 │
10 │ func test() {
11 │ S().discardableGetter
│ ╰─ warning: expression of type 'Int' is unused
12 │ }
Expected behavior
@discardableResult
could suppress this warning.
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
also occur in nightly:
Swift version 6.0-dev (LLVM a8cd54c4da01fef, Swift e738059)
Target: arm64-apple-macosx14.0
Additional information
Similar to #71870 .
Metadata
Metadata
Assignees
Labels
Feature → attributes: The @discardableResult attributeFeature → declarations: Variable (property) accessorsFeature: Declaration and type attributesA deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfFeature: declarationsArea → compiler: Semantic analysisBug: Unexpected behavior or incorrect output