We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xcode Version 13.0 beta (13A5155e)
iOS project that supports only iOS 15.0
macOS Big Sur (11.4)
md5: a91d316bf25240ba8cc082b021837de8
Issue Description:
Hi,
I have the following code that throws a compilation error.
Overview
I have an async let p1 statement
async let p1
Then I have 2 statements that await on p1
await
p1
Removing one of those 2 awaits removes the error
Compilation error: Immutable value 'p1' may only be initialized once
Immutable value 'p1' may only be initialized once
Tested on:
Code:
import Foundation func f1() { async { async let p1 = computePrice() //Immutable value 'p1' may only be initialized once print(await p1) let k = await p1 } } func computePrice() async -> Int { await withCheckedContinuation { continuation in DispatchQueue.main.asyncAfter(deadline: .now() + 4) { continuation.resume(returning: 10) } } }
It looks like a bug, let me know if I am missing something. Thanks.
The text was updated successfully, but these errors were encountered:
Reduced example
func f() async -> Int { 1 } func g() { async { async let x = f() print(await x) let y = await x } }
To work around this bug, you can create a binding for await x and reuse that later.
await x
@swift-ci create
Sorry, something went wrong.
No branches or pull requests
Environment
Xcode Version 13.0 beta (13A5155e)
iOS project that supports only iOS 15.0
macOS Big Sur (11.4)
Additional Detail from JIRA
md5: a91d316bf25240ba8cc082b021837de8
Issue Description:
Hi,
I have the following code that throws a compilation error.
Overview
I have an
async let p1
statementThen I have 2 statements that
await
onp1
Removing one of those 2 awaits removes the error
Compilation error:
Immutable value 'p1' may only be initialized once
Tested on:
Xcode Version 13.0 beta (13A5155e)
iOS project that supports only iOS 15.0
macOS Big Sur (11.4)
Code:
It looks like a bug, let me know if I am missing something. Thanks.
The text was updated successfully, but these errors were encountered: