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

No warning or error is thrown when an instance of a class with mutable state instance is assigned to Sendable variable #60054

Closed
muthuveerappanal opened this issue Jul 14, 2022 · 1 comment
Labels
accepts invalid Bug: Accepts invalid bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself concurrency Feature: umbrella label for concurrency language features conformances Feature → protocol: protocol conformances Sendable Area → standard library: The Sendable protocol swift 5.9 type checker Area → compiler: Semantic analysis

Comments

@muthuveerappanal
Copy link

muthuveerappanal commented Jul 14, 2022

Describe the bug
On Swift 5.7 (see environment) when an instance of a class with a mutable state is assigned to a Sendable variable, no warning error or error is thrown

class Engine {}

class Car {
    var engine: Engine
    init(engine: Engine) {
        self.engine = engine
    }
}

var car = Car(engine: Engine())
let s: Sendable = car

Steps To Reproduce

  1. Using the environment mentioned below, create an Xcode command line project with the code mentioned above
  2. Compile the code

Expected behavior
An error or warning needs to be thrown compiling the line let s: Sendable = car

Environment

  • OS: 13.0 Beta (22A5295i)
  • Xcode Version 14.0 beta 3 (14A5270f)
  • Xcode command line project
@muthuveerappanal muthuveerappanal added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Jul 14, 2022
@LucianoPAlmeida LucianoPAlmeida added concurrency Feature: umbrella label for concurrency language features type checker Area → compiler: Semantic analysis labels Jul 16, 2022
@AnthonyLatsis AnthonyLatsis added the compiler The Swift compiler itself label Dec 13, 2022
@hborla
Copy link
Member

hborla commented Jan 23, 2024

This is diagnosed under -strict-concurrency=complete in Swift 5.10

warning: type 'Car' does not conform to the 'Sendable' protocol
let s: Sendable = car
                  ^
note: class 'Car' does not conform to the 'Sendable' protocol
class Car {
      ^

@hborla hborla closed this as completed Jan 23, 2024
@AnthonyLatsis AnthonyLatsis added accepts invalid Bug: Accepts invalid swift 5.9 Sendable Area → standard library: The Sendable protocol conformances Feature → protocol: protocol conformances labels Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepts invalid Bug: Accepts invalid bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself concurrency Feature: umbrella label for concurrency language features conformances Feature → protocol: protocol conformances Sendable Area → standard library: The Sendable protocol swift 5.9 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants