-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
@autoclosureFeature → attributes: the @autoclosure type attributeFeature → attributes: the @autoclosure type attributeasync & awaitFeature → concurrency: asynchronous function aka the async/await patternFeature → concurrency: asynchronous function aka the async/await patternbugA 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 itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresoverload resolutionArea → compiler → type checker: Overload resolution (ranking)Area → compiler → type checker: Overload resolution (ranking)swift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error
Description
Description
I have two functions; one that takes an async closure and one that doesn't. Then they invoke it, so the first is async itself and the second is not. I would expect that passing in an async closure or not would allow the compiler to select between them, but this does not seem the case.
Steps to reproduce
func foo(_ expression: @autoclosure () -> Int) {
_ = expression()
}
func foo(_ expression: @autoclosure () async -> Int) async {
_ = await expression()
}
foo(1)
await foo(await 1)
Expected behavior
This should compile without issues
Environment
- Swift compiler version info swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.51 clang-1500.1.0.2.2)
Target: arm64-apple-macosx14.0 - Xcode version info
Xcode 15.1
Build version 15C5042i - Deployment target: macOS 14.2
Additional context
$ swiftc test.swift
test.swift:11:11: error: 'await' in an autoclosure that does not support concurrency
await foo(await 1)
^
test.swift:11:1: warning: no 'async' operations occur within 'await' expression
await foo(await 1)
^
error: fatalError
JessyCatterwaul and qusc
Metadata
Metadata
Assignees
Labels
@autoclosureFeature → attributes: the @autoclosure type attributeFeature → attributes: the @autoclosure type attributeasync & awaitFeature → concurrency: asynchronous function aka the async/await patternFeature → concurrency: asynchronous function aka the async/await patternbugA 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 itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresoverload resolutionArea → compiler → type checker: Overload resolution (ranking)Area → compiler → type checker: Overload resolution (ranking)swift 6.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorBug: Unexpected error