-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
@discardableResultFeature → attributes: The @discardableResult attributeFeature → attributes: The @discardableResult attributeaccessorsFeature → declarations: Variable (property) accessorsFeature → declarations: Variable (property) accessorsattributesFeature: Declaration and type attributesFeature: Declaration and type attributesbugA 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 itselfdeclarationsFeature: declarationsFeature: declarationsswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output
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
@discardableResultFeature → attributes: The @discardableResult attributeFeature → attributes: The @discardableResult attributeaccessorsFeature → declarations: Variable (property) accessorsFeature → declarations: Variable (property) accessorsattributesFeature: Declaration and type attributesFeature: Declaration and type attributesbugA 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 itselfdeclarationsFeature: declarationsFeature: declarationsswift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output