Skip to content

debugDescription of KeyPath may generate incorrect string representations #81508

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

Open
almazrafi opened this issue May 14, 2025 · 2 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@almazrafi
Copy link

almazrafi commented May 14, 2025

Description

I've encountered an issue where the debugDescription property of KeyPath can produce incorrect string representations.

Reproduction

struct Foo { }
struct Bar { }

struct Foobar {
    let foo: Foo
    let bar: Bar
}

print(\Foobar.foo) // prints: '\Foobar.foo'
print(\Foobar.bar) // prints: '\Foobar.foo'  <-- unexpected, should be '\Foobar.bar'

Expected behavior

The second print statement should output \Foobar.bar, matching the key path's property name.

Environment

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

Additional information

No response

@almazrafi almazrafi added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 14, 2025
@almazrafi almazrafi changed the title debugDescription of KeyPath may generate incorrect string representations debugDescription of KeyPath may generate incorrect string representations May 14, 2025
@jamieQ
Copy link
Contributor

jamieQ commented May 14, 2025

looks kind of similar to #79721 which was closed as 'not planned'. this comment may be relevant: #79721 (comment)

@almazrafi
Copy link
Author

looks kind of similar to #79721 which was closed as 'not planned'. this comment may be relevant: #79721 (comment)

No, this issue is not related to optimization and occurs even with optimization disabled (-O0).

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

2 participants