Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Hole in region checker when bundling non-Sendable into an array. #89134

@mbrandonw

Description

@mbrandonw

Description

If you pass an array of a non-Sendable object to an actor initializer, the object is not isolated to the actor's region. Same happens with dictionaries and sets.

This only seems to affect Xcode versions of Swift. I could not reproduce this on any version of Swift since 6.0.3 in godbolt: https://godbolt.org/z/xP1KGdfTE

Reproduction

class NS { var count = 0 }
actor MyActor {
  init(_ ns: [NS]) {}
}
func hole() {
  let ns = NS()
  let actor = MyActor([ns])
  ns.count += 1  // This should fail to compile but does not
  _ = actor
}

Expected behavior

Compiler should reject code since we are accessing ns after it has been sent to the actor.

Environment

swift-driver version: 1.148.6 Apple Swift version 6.3.2 (swiftlang-6.3.2.1.103 clang-2100.1.1.101)
Target: arm64-apple-macosx26.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    actor isolationFeature → concurrency: Actor isolationbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresregion-based isolation checker

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions