# Loosing type info depending on iteration mode

**URL:** <https://forums.swift.org/t/loosing-type-info-depending-on-iteration-mode/65250>\
**Category:** Using Swift\
**Tags:** generics\
**Created:** [May 29, 2023, 3:20pm UTC](https://forums.swift.org/t/loosing-type-info-depending-on-iteration-mode/65250 "2023-05-29T15:20:09Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [May 29, 2023, 4:16pm UTC](https://forums.swift.org/t/loosing-type-info-depending-on-iteration-mode/65250/4 "2023-05-29T16:16:30Z")

</div>

> [@For-in vs forEach() when sequence element is Dictionary.Key](https://forums.swift.org/t/for-in-vs-foreach-when-sequence-element-is-dictionary-key/64053/2):
>
> First off, you probably know this, but both f1 and f2 should really take arguments of type some Sequence\<Key\>, not any, which would make the error go away. As I understand it, this is a known limitation that could be lifted in the future. Let me try to break it down. Starting with f2: forEach can preserve the concrete Key type thanks to [Covariant Erasure with Constrained Existentials](https://github.com/apple/swift-evolution/blob/main/proposals/0353-constrained-existential-types.md#covariant-erasure-with-constrained-existentials) in SE-0353: Constrained Existential Types. So this is relatively straightforward. In the case of f1, the com…

---

_[View the full topic](https://forums.swift.org/t/loosing-type-info-depending-on-iteration-mode/65250)._
