Skip to content

Appending a writable/sendable key path loses writability #75531

Open
@stephencelis

Description

@stephencelis

Description

The new sendable key path diagnostics seems to lose writability when appending a sendable, writable key path.

Reproduction

struct S {
  var p = 0
}
struct T {
  var s = S()
}
func f() {
  let kp1: WritableKeyPath<T, S> & Sendable = \T.s
  let kp2: WritableKeyPath<T, Int> & Sendable = kp1.appending(path: \.p)
}

Expected behavior

kp2 should compile, but we get:

Error: Cannot convert value of type 'KeyPath<T, Int>' to specified type 'WritableKeyPath<T, Int>'

Environment

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

Additional information

No response

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 featureskey pathsFeature: key paths (both native and Objective-C)standard libraryArea: Standard library umbrella

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions