swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.19k stars 10.32k forks source link

Swift 6.0.0.5 concurrency regression with default argument value #75105

Closed NachoSoto closed 1 day ago

NachoSoto commented 1 month ago

Description

The following code compiles fine with Xcode 16 beta 2 but fails with beta 3.

Reproduction

actor Actor {
  func f() throws {
    Task { [weak self] in
      // Sending 'self'-isolated value of type 'Int' with later accesses to actor-isolated context risks causing data races
      await self?.g()
    }
  }

  private func g(_ n: Int = 1) async -> Int { n }
}

Expected behavior

Compiles

Environment

swift-driver version: 1.111.2 Apple Swift version 6.0 (swiftlang-6.0.0.5.15 clang-1600.0.22.6)
Target: arm64-apple-macosx14.0

Additional information

No response

NachoSoto commented 1 month ago

cc @hborla

hborla commented 1 month ago

@gottesmm this code compiles without errors under -swift-version 6 on main - any idea which region isolation change fixed it? We should check in the test case.

ArchiProger commented 1 month ago

There was the same problem. Do you have any ideas for a solution?

dfed commented 1 month ago

In case it's helpful, this is still an issue in Xcode 16.0 Beta 4 running the following Swift version:

swift-driver version: 1.112.3 Apple Swift version 6.0 (swiftlang-6.0.0.6.8 clang-1600.0.23.1)
Target: arm64-apple-macosx14.0
NachoSoto commented 1 month ago

Same as #75106, this still reproduces with beta 4 when compiling with -warnings-as-errors -warn-concurrency @hborla

Edit: actually also reproduces compiling with swift -swift-version 6 file.swift

hborla commented 1 month ago

I don't think @gottesmm's fixes are included in Beta 4

NachoSoto commented 1 month ago

So the Swift version in beta 4 is over 2 weeks old?

gottesmm commented 1 month ago

This was fixed by #74757

hborla commented 1 month ago

So the Swift version in beta 4 is over 2 weeks old?

Yes, there is a delay for changes that land on release/6.0 to make it into an Xcode beta, because the changes go through additional testing first.

dfed commented 2 days ago

This seems to be fixed in the Xcode 16.0b6 release!

gottesmm commented 1 day ago

@dfed Thanks for verifying! Closing!