Avatar
omochimetaru 6/23/2025 3:12 AM
@swift-main @dynamicMemberLookup public struct OptionalJoin<each V: Codable> { public init(_ v: repeat (each V)?) { self.v = (repeat each v) } public var v: (repeat (each V)?) public subscript<T>(dynamicMember keyPath: KeyPath<(repeat (each V)?), T>) -> T { v[keyPath: keyPath] } } func direct(x: OptionalJoin<Int, String>) -> String? { return x.v.1 } func explicitDML(x: OptionalJoin<Int, String>) -> String? { return x[dynamicMember: \.1] } func dml(x: OptionalJoin<Int, String>) -> String? { // error: Type of expression is ambiguous without a type annotation return x.1 }