Skip to content

async let + sending doesn't seem to work #76727

Closed
@mattmassicotte

Description

@mattmassicotte

Description

I was trying to get around returning a non-Sendable type from a synchronous function. I thought I'd be able to use sending to deal with this, but it doesn't seem to work.

Reproduction

class NonSendable {}

@MainActor
func f() async {
	async let x = g()
	// error: non-sendable type 'NonSendable' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary
	_ = await x
}

func g() -> sending NonSendable {
	NonSendable()
}

await f()

Expected behavior

I would expect this to compile warning-free.

Environment

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.11 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions