Skip to content

Confusing error message for conflicting isolation when both are actor-instance isolated #84519

@hborla

Description

@hborla

Description

Actor-instance isolation shows up as "actor-isolated" in diagnostics. This leads to very confusing errors when you have mismatching isolation with two different actor instances, because the two isolations have the exact same description in the error message. Using the types won't help because it's common for those to be the same too. We should try to use the name of the actor variables, which are often different.

Example of confusion: https://www.reddit.com/r/iOSProgramming/comments/1noix4e/did_apple_out_source_they_error_message_xcode_wtf/

Reproduction

actor MyActor {
  static let shared = MyActor()

  var name: String = ""

  // 'MyActor.shared' might not be the same value as 'self'
  func ohNo(_: String = MyActor.shared.name) {}
}

Expected behavior

The above code should produce an error that makes it clear that self and MyActor.shared could be different values, so state isolated to MyActor.shared can't be used because default arguments can only be isolated to self.

Environment

All Swift versions when IsolatedDefaultValues is enabled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions