Skip to content

@discardableResult on global actor-isolated function is ignored #83463

@nickolas-pohilets

Description

@nickolas-pohilets

Description

@discardableResult stops working when function is isolated to a global actor.

Reproducible in Swift 5 and Swift 6 modes. Does not reproduce when functions are isolated to an actor instance.

Reproduction

// Order of attributes does not matter
// Removing isolation attribute fixes the error
@discardableResult @MainActor
func foo() -> () -> Void {
    return {}
}

@MainActor
func test() {
    foo() // error: function is unused
}

Expected behavior

Code should compiler without error

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions