Skip to content
New issue

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

Mutation of captured var 'ocean' in concurrently-executing code #1237

Closed
lukeistutoring opened this issue Aug 6, 2023 · 1 comment
Closed

Comments

@lukeistutoring
Copy link

  • [ x] I have read CONTRIBUTING and have done my best to follow them.

What did you do?

Created AsynchronousSpec according to example in #1217

What did you expect to happen?

Test to compile and run

What actually happened instead?

Test fails to compile with Mutation of captured var 'ocean' in concurrently-executing code

Environment

List the software versions you're using:

  • Quick: 7.2.0
  • Nimble: 12.2.0
  • Xcode Version: 14.3.1 (14E300c) (Open Xcode; In menubar: Xcode > About Xcode)
  • Swift Version: Xcode Default (Open Xcode Preferences; Components > Toolchains. If none, use Xcode Default.)

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

  • CocoaPods: 1.21.1 (Use pod --version in Terminal)
  • Carthage: ?.? (Use carthage version in Terminal)
  • Swift Package Manager ?.?.? (swiftpm-???) (Use swift build --version in Terminal)

Project that demonstrates the issue

import Quick
import Nimble

class AsynchronousSpec: AsyncSpec {
    override class func spec() {
        it("runs the test in an async context") {
            var ocean: [String] = []
            DispatchQueue.main.async {
                ocean.append("dolphins")
                ocean.append("whales")
            }
            await expect(ocean).toEventually(contain("dolphins", "whales"))
        }
    }
}
@younata
Copy link
Member

younata commented Aug 6, 2023

Yep. That's correct. The example will have to be updated.

Edit: The example linked (and the release page) have now been updated with code that compiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants