swift icon indicating copy to clipboard operation
swift copied to clipboard

Swift 6.0.0.5 concurrency regression with default argument value

Open NachoSoto opened this issue 1 year ago • 3 comments

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 avatar Jul 09 '24 16:07 NachoSoto

cc @hborla

NachoSoto avatar Jul 10 '24 05:07 NachoSoto

@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.

hborla avatar Jul 10 '24 15:07 hborla

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

ArchiProger avatar Jul 10 '24 20:07 ArchiProger

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

dfed avatar Jul 23 '24 19:07 dfed

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

NachoSoto avatar Jul 23 '24 21:07 NachoSoto

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

hborla avatar Jul 23 '24 22:07 hborla

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

NachoSoto avatar Jul 23 '24 22:07 NachoSoto

This was fixed by #74757

gottesmm avatar Jul 23 '24 23:07 gottesmm

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.

hborla avatar Jul 23 '24 23:07 hborla

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

dfed avatar Aug 22 '24 18:08 dfed

@dfed Thanks for verifying! Closing!

gottesmm avatar Aug 23 '24 16:08 gottesmm