-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
@dynamicMemberLookupFeature → attributes: the @dynamicMemberLookup attributeFeature → attributes: the @dynamicMemberLookup attributeAnyKeyPathArea → standard library: The `AnyKeyPath` typeArea → standard library: The `AnyKeyPath` typeCustomDebugStringConvertibleArea → standard library: The `CustomDebugStringConvertible` protocolArea → standard library: The `CustomDebugStringConvertible` protocolattributesFeature: Declaration and type attributesFeature: Declaration and type attributesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdeclarationsFeature: declarationsFeature: declarationsdemanglingArea → compiler: The `libswiftDemangling` libraryArea → compiler: The `libswiftDemangling` librarygenericsFeature: generic declarations and typesFeature: generic declarations and typeskey pathsFeature: key paths (both native and Objective-C)Feature: key paths (both native and Objective-C)standard libraryArea: Standard library umbrellaArea: Standard library umbrellasubscriptFeature: Subscript declarationsFeature: Subscript declarationsswift 5.9unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output
Description
Motivation
In Swift 5.8 there was a runtime crash in AnyKeyPath.debugDescription
that was fixed in #63305. However, the fix did the bare minimum to not crash, but the description of the key path is not great:
struct Foo {
subscript<A>(_ a: A) -> A { a }
}
print(\Foo.[1])
// "\Foo.<computed 0x0000000105129928 (Int)>"
Ideally it would be great if it could be printed like so:
print(\Foo.[1])
// "\Foo.[1]"
Further, if possible, it would also be really great if dynamic members could be given special treatment to be printed nicely:
@dynamicMemberLookup
struct Wrapper<Value> {
let value: Value
subscript<OtherValue>(dynamicMember keyPath: KeyPath<Value, OtherValue>) -> OtherValue {
self.value[keyPath: keyPath]
}
}
print(\Wrapper<String>.count)
// Should print "\Wrapper<String>.count"
// instead of "\Wrapper<String>.[dynamicMember: \String.count]"
Metadata
Metadata
Assignees
Labels
@dynamicMemberLookupFeature → attributes: the @dynamicMemberLookup attributeFeature → attributes: the @dynamicMemberLookup attributeAnyKeyPathArea → standard library: The `AnyKeyPath` typeArea → standard library: The `AnyKeyPath` typeCustomDebugStringConvertibleArea → standard library: The `CustomDebugStringConvertible` protocolArea → standard library: The `CustomDebugStringConvertible` protocolattributesFeature: Declaration and type attributesFeature: Declaration and type attributesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdeclarationsFeature: declarationsFeature: declarationsdemanglingArea → compiler: The `libswiftDemangling` libraryArea → compiler: The `libswiftDemangling` librarygenericsFeature: generic declarations and typesFeature: generic declarations and typeskey pathsFeature: key paths (both native and Objective-C)Feature: key paths (both native and Objective-C)standard libraryArea: Standard library umbrellaArea: Standard library umbrellasubscriptFeature: Subscript declarationsFeature: Subscript declarationsswift 5.9unexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output