-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
@dynamicMemberLookupFeature → attributes: the @dynamicMemberLookup attributeFeature → attributes: the @dynamicMemberLookup attributebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresexpressionsFeature: expressionsFeature: expressionstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Description
If a dynamic member subscript is limited to sendable key paths, this check is only performed when invoking the dynamic member directly.
Reproduction
@dynamicMemberLookup
struct S<T> {
subscript<U>(dynamicMember keyPath: KeyPath<T, U> & Sendable) -> U {
fatalError()
}
}
public struct Foo {
subscript<T>(bar bar: T) -> Int { 42 }
}
public struct NonSendable: Hashable {}
func f() {
let s = S<Foo>()
s[dynamicMember: \.[bar: NonSendable()]] // ❌ Fails to compile
s[bar: NonSendable()] // ✅ Compiles when it shouldn't
}
Expected behavior
I expect both lines to fail to compiles.
Environment
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
Additional information
No response
Metadata
Metadata
Assignees
Labels
@dynamicMemberLookupFeature → attributes: the @dynamicMemberLookup attributeFeature → attributes: the @dynamicMemberLookup attributebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresexpressionsFeature: expressionsFeature: expressionstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis