# \#dynamicmemberlookup

**URL:** https://forums.swift.org/tag/dynamicmemberlookup/304.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [BrainF\*\*\* in the Swift type system](https://forums.swift.org/t/brainf-in-the-swift-type-system/68301)

<div class="topic-metadata">

**Author:** [@KeithBauerANZ](https://forums.swift.org/u/KeithBauerANZ)\
**Replies:** 18\
**Last updated:** [July 11, 2026, 1:42am UTC](https://forums.swift.org/t/brainf-in-the-swift-type-system/68301 "2026-07-11T01:42:29Z")

</div>

Swift's type system is Turing-complete. The result was known (not to me when I went down this rabbit hole; I did this all on the speculation that Swift's type system is Turing complete), but I've not seen anyone prove it…

---

## [@dynamicMemberLookup + nested KeyPath access not triggering my custom observation access tracking](https://forums.swift.org/t/dynamicmemberlookup-nested-keypath-access-not-triggering-my-custom-observation-access-tracking/84165)

<div class="topic-metadata">

**Author:** [@Blacksmith](https://forums.swift.org/u/Blacksmith)\
**Replies:** 1\
**Last updated:** [January 15, 2026, 8:44pm UTC](https://forums.swift.org/t/dynamicmemberlookup-nested-keypath-access-not-triggering-my-custom-observation-access-tracking/84165 "2026-01-15T20:44:12Z")

</div>

Hello everyone, I’m experimenting with a custom observation mechanism for value-type State (similar in spirit to @Observable, but without macros). While doing that, I ran into an unexpected behavior involving @dynamicMe…

---

## [@dynamicMemberLookup via another @dynamicMemberLookup](https://forums.swift.org/t/dynamicmemberlookup-via-another-dynamicmemberlookup/68048)

<div class="topic-metadata">

**Author:** [@jeudesprits](https://forums.swift.org/u/jeudesprits)\
**Replies:** 2\
**Last updated:** [May 22, 2025, 12:00pm UTC](https://forums.swift.org/t/dynamicmemberlookup-via-another-dynamicmemberlookup/68048 "2025-05-22T12:00:16Z")

</div>

On the example of AttributedString type it is not very clear how the dynamicMemberLookup chaining works from @dynamicMemberLookup struct AttributedString { subscript\<K\>(dynamicMember keyPath: Swift.KeyPath\<Attribut…

---

## [\[Pitch\] Allow Additional Arguments to @dynamicMemberLookup Subscripts](https://forums.swift.org/t/pitch-allow-additional-arguments-to-dynamicmemberlookup-subscripts/79558)

<div class="topic-metadata">

**Author:** [@itaiferber](https://forums.swift.org/u/itaiferber)\
**Replies:** 16\
**Last updated:** [May 6, 2025, 7:26pm UTC](https://forums.swift.org/t/pitch-allow-additional-arguments-to-dynamicmemberlookup-subscripts/79558 "2025-05-06T19:26:41Z")

</div>

Following up from @dynamicMemberLookup subscript with additional (defaulted) arguments?, I've put together a brief proposal to allow additional arguments to dynamic member lookup subscripts (so long as they have default …

---

## [Wrapping C structs with @dynamicMemberLookup and friends](https://forums.swift.org/t/wrapping-c-structs-with-dynamicmemberlookup-and-friends/70658)

<div class="topic-metadata">

**Author:** [@wadetregaskis](https://forums.swift.org/u/wadetregaskis)\
**Replies:** 16\
**Last updated:** [March 14, 2024, 11:29am UTC](https://forums.swift.org/t/wrapping-c-structs-with-dynamicmemberlookup-and-friends/70658 "2024-03-14T11:29:56Z")

</div>

Continuing the discussion from Byte-sized Swift: Building Tiny Games for the Playdate: Good question. The following is mostly coded here in the Forums, i.e. may not actually compile or execute correctly. I'm just the…

---

## [dynamicMemberLookup bug?](https://forums.swift.org/t/dynamicmemberlookup-bug/65593)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 2\
**Last updated:** [June 15, 2023, 1:14pm UTC](https://forums.swift.org/t/dynamicmemberlookup-bug/65593 "2023-06-15T13:14:52Z")

</div>

I have this struct: struct Foo { var name: String = "hello" var count: Int = 42 } When I add @dynamicMemberLookup on it compiler rightfully complains: So, I've added the relevant subscript implementation: @d…

---

## [Query into dynamic data using static key paths](https://forums.swift.org/t/query-into-dynamic-data-using-static-key-paths/36728)

<div class="topic-metadata">

**Author:** [@lightsprint09](https://forums.swift.org/u/lightsprint09)\
**Replies:** 4\
**Last updated:** [March 10, 2023, 6:55am UTC](https://forums.swift.org/t/query-into-dynamic-data-using-static-key-paths/36728 "2023-03-10T06:55:28Z")

</div>

Hello, I am currently porting Automerge to swift. It is a CRDT. You can create a document, sync the content to different devices, edit concurrently, sync it back and end up with consistent data on every device. (It is a…

---

## [\[Mistake\] Member not found when accessing a value through two conditional subscripts](https://forums.swift.org/t/mistake-member-not-found-when-accessing-a-value-through-two-conditional-subscripts/61017)

<div class="topic-metadata">

**Author:** [@RemiBardon](https://forums.swift.org/u/RemiBardon)\
**Replies:** 5\
**Last updated:** [October 26, 2022, 6:44am UTC](https://forums.swift.org/t/mistake-member-not-found-when-accessing-a-value-through-two-conditional-subscripts/61017 "2022-10-26T06:44:19Z")

</div>

TLDR Original Post Context: I'm writing a generic geographical library. I already introduced it in Wrong “Redundant conformance constraint” warning when I encountered a bogus with the generics system. I'm completely r…

---

## [Observing variable access using dynamic lookup wrapper](https://forums.swift.org/t/observing-variable-access-using-dynamic-lookup-wrapper/60729)

<div class="topic-metadata">

**Author:** [@fabstu](https://forums.swift.org/u/fabstu)\
**Replies:** 0\
**Last updated:** [October 8, 2022, 12:46pm UTC](https://forums.swift.org/t/observing-variable-access-using-dynamic-lookup-wrapper/60729 "2022-10-08T12:46:34Z")

</div>

Hello, I want to have an object that observes and records what values get accessed from a stored variable and dynamically lookup the stored variables' values on access (that part works). But if no dynamic lookup (access…

---

## [Question about using @dynamicMemberLookup with enum KeyPath](https://forums.swift.org/t/question-about-using-dynamicmemberlookup-with-enum-keypath/50327)

<div class="topic-metadata">

**Author:** [@miku1958](https://forums.swift.org/u/miku1958)\
**Replies:** 1\
**Last updated:** [July 9, 2021, 5:40pm UTC](https://forums.swift.org/t/question-about-using-dynamicmemberlookup-with-enum-keypath/50327 "2021-07-09T17:40:27Z")

</div>

Hi, I have an idea for adding @dynamicMemberLookup to an OptionSet and using an enum as it's dynamicMember, such as: @dynamicMemberLookup struct TestOption: OptionSet { let rawValue: UInt enum Options: UInt { case o…

---

## [\[Question\] Limitation in 'depth' of multiple KeyPath member lookup](https://forums.swift.org/t/question-limitation-in-depth-of-multiple-keypath-member-lookup/47318)

<div class="topic-metadata">

**Author:** [@ensan-hcl](https://forums.swift.org/u/ensan-hcl)\
**Replies:** 1\
**Last updated:** [April 12, 2021, 2:05pm UTC](https://forums.swift.org/t/question-limitation-in-depth-of-multiple-keypath-member-lookup/47318 "2021-04-12T14:05:23Z")

</div>

Now I have following property wrapper using dynamic member lookup. @propertyWrapper @dynamicMemberLookup private struct AddSubscript\<T, S\> { var wrappedValue: T init(wrappedValue: T, type: S.Type) { sel…

---

## [Using a protocol to more easily implement copy-on-write](https://forums.swift.org/t/using-a-protocol-to-more-easily-implement-copy-on-write/47130)

<div class="topic-metadata">

**Author:** [@nikitamounier](https://forums.swift.org/u/nikitamounier)\
**Replies:** 10\
**Last updated:** [April 8, 2021, 8:55am UTC](https://forums.swift.org/t/using-a-protocol-to-more-easily-implement-copy-on-write/47130 "2021-04-08T08:55:40Z")

</div>

I was watching a great talk recently by @johannesweiss called "High-performance systems in Swift", where he talked about the importance of copy-on-write for large value types in high-performance systems (which is already…

---

## [How do I use dynamic member lookup in a generic property wrapper to return the looked-up member wrapped by the same property wrapper?](https://forums.swift.org/t/how-do-i-use-dynamic-member-lookup-in-a-generic-property-wrapper-to-return-the-looked-up-member-wrapped-by-the-same-property-wrapper/43725)

<div class="topic-metadata">

**Author:** [@wowbagger](https://forums.swift.org/u/wowbagger)\
**Replies:** 9\
**Last updated:** [January 11, 2021, 4:28pm UTC](https://forums.swift.org/t/how-do-i-use-dynamic-member-lookup-in-a-generic-property-wrapper-to-return-the-looked-up-member-wrapped-by-the-same-property-wrapper/43725 "2021-01-11T16:28:26Z")

</div>

Sorry the title is a mouthful. Basically this is what I'm trying to do: @propertyWrapper @dynamicMemberLookup struct Wrapper\<Wrapped\> { var wrappedValue: Wrapped subscript\<Member\>( dynamicMember keyPath: Writable…

---

## [Ambiguous type of expression with dynamic member lookup applied to wrapper holding optional type with property wrapped value](https://forums.swift.org/t/ambiguous-type-of-expression-with-dynamic-member-lookup-applied-to-wrapper-holding-optional-type-with-property-wrapped-value/38718)

<div class="topic-metadata">

**Author:** [@ilyapuchka](https://forums.swift.org/u/ilyapuchka)\
**Replies:** 2\
**Last updated:** [July 24, 2020, 12:52pm UTC](https://forums.swift.org/t/ambiguous-type-of-expression-with-dynamic-member-lookup-applied-to-wrapper-holding-optional-type-with-property-wrapped-value/38718 "2020-07-24T12:52:25Z")

</div>

Hi. I'm trying to figure out the way to access projected values of custom wrappers holding optional values and face Type of expression is ambiguous without more context errors in Swift 5.2.4 (Xcode 11.5). Here is the cod…

---

## [KeyPath @dynamicMemberLookup does not compile using implicit self](https://forums.swift.org/t/keypath-dynamicmemberlookup-does-not-compile-using-implicit-self/32622)

<div class="topic-metadata">

**Author:** [@ebg](https://forums.swift.org/u/ebg)\
**Replies:** 4\
**Last updated:** [January 15, 2020, 11:28pm UTC](https://forums.swift.org/t/keypath-dynamicmemberlookup-does-not-compile-using-implicit-self/32622 "2020-01-15T23:28:49Z")

</div>

It seems you cannot use implicit self when using dynamic member keypaths. This is a departure from conventional Swift code and appears to be a bug in the compiler. See the error below: public protocol TestProtocol { …

---

## [@dynamicMemberLookup keyPaths not working with generic classes?](https://forums.swift.org/t/dynamicmemberlookup-keypaths-not-working-with-generic-classes/31688)

<div class="topic-metadata">

**Author:** [@ebg](https://forums.swift.org/u/ebg)\
**Replies:** 2\
**Last updated:** [December 15, 2019, 4:22pm UTC](https://forums.swift.org/t/dynamicmemberlookup-keypaths-not-working-with-generic-classes/31688 "2019-12-15T16:22:35Z")

</div>

I've added dynamicMemberLookup keypath support to a generic class in hopes of achieving forwarding to the underlying type. This compiles and runs, and seems like it will work: @dynamicMemberLookup open class BaseClass\<G…
