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

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

Open
jamesmmadeira opened this issue Sep 30, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@jamesmmadeira
Copy link

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).

@jamesmmadeira jamesmmadeira added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant