Skip to content

debugDescription of KeyPath may generate incorrect string representations #81508

Open
@almazrafi

Description

@almazrafi

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

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