Skip to content

Using a key path on a consumed object causes "copy of noncopyable typed value" warning. #76775

Open
@jamesmmadeira

Description

@jamesmmadeira

Description

Compiling code that uses a ReferenceWritableKeyPath on an instance that has been constrained to AnyObject results in the error "copy of noncopyable typed value. This is a compiler bug. Please file a bug with a small example of the bug".

Reproduction

func assign<Resource, Target: AnyObject>(
  target: consuming Target,
  path: ReferenceWritableKeyPath<Target, Resource>,
  source: Resource
) {
  target[keyPath: path] = source
}

Expected behavior

Using a key path in this fashion does not result in an error.

Environment

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx15.0

Additional information

You can work around it by re-declaring the variable (like let target = target).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions