# How to use pattern match for overloaded enum?

**URL:** <https://forums.swift.org/t/how-to-use-pattern-match-for-overloaded-enum/48768>\
**Category:** Using Swift\
**Created:** [May 24, 2021, 3:07am UTC](https://forums.swift.org/t/how-to-use-pattern-match-for-overloaded-enum/48768 "2021-05-24T03:07:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ensan-hcl](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ensan-hcl/32/15186_2.png) [@ensan-hcl](https://forums.swift.org/u/ensan-hcl)\
**Post date:** [May 24, 2021, 3:07am UTC](https://forums.swift.org/t/how-to-use-pattern-match-for-overloaded-enum/48768/1 "2021-05-24T03:07:58Z")

</div>

It compiles fine.

```nohighlight
enum EnumOverload {
    case value(int: Int)
    case value(string: String)
    case value(bool: Bool)
}

```

I can use `EnumOverload.value(int: 42)` and the similar with no problem, but on the pattern match it cannot used.

This is the code Xcode generated for `swiftch`, but it causes error.

```nohighlight
extension EnumOverload: CustomStringConvertible {
    var description: String {
        switch self {
        case .value(int: let int): return "\(int)"
        case .value(string: let string): return "\(string)"
        case .value(bool: let bool): return "\(bool)"
        }
    }
}

```

As far as I know, there is no way to use label on pattern match. Is it possible to use pattern match for this enum? And if it is impossible, for what this overload is allowed?

---

<div class="post-metadata">

**Author:** ![xAlien95](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/xalien95/32/12558_2.png) [@xAlien95](https://forums.swift.org/u/xAlien95)\
**Post date:** [May 24, 2021, 3:56am UTC](https://forums.swift.org/t/how-to-use-pattern-match-for-overloaded-enum/48768/2 "2021-05-24T03:56:37Z")

</div>

It's a known bug. [SE-0155, Expired Proposal](https://github.com/apple/swift-evolution/blob/aecced4919ab297f343dafd7235d392d8b859839/proposals/0155-normalize-enum-case-representation.md#disambiguating-pattern-matches) contained a detailed description of what should've happened in case of same base-name cases,

> [@](#):
>
> If there are no unlabeled associated values and there are multiple labeled associated values with the same arity, then an unlabeled pattern is ambiguous. Explicit labels can be used to disambiguate:
> 
> ```swift
> enum Buffalo {
> case buffalo(bill: String)
> case buffalo(buffalo: String)
> }
> 
> switch buffalo {
> case .buffalo(_): // Error, ambiguous
> case .buffalo(bill: _): // Favors `buffalo(bill:)`
> case .buffalo(buffalo: _): // Favors `buffalo(buffalo:)`
> }
> 
> ```

but due to the new expiration policies and the fact that SE-0155 hasn't been fully implemented in an year from its acceptance, that section has been removed. You can read more in [Addressing unimplemented evolution proposals](https://forums.swift.org/t/addressing-unimplemented-evolution-proposals/40322).

> [@Addressing unimplemented evolution proposals](https://forums.swift.org/t/addressing-unimplemented-evolution-proposals/40322/1):
>
> - [SE-0155](https://github.com/apple/swift-evolution/blob/master/proposals/0155-normalize-enum-case-representation.md) is partly implemented. The portion relating to changes to pattern matching behavior will be removed. There are also some bugs in the implementation ([SR-12206](https://bugs.swift.org/browse/SR-12206) and [SR-12229](https://bugs.swift.org/browse/SR-12229)) which should be treated as existing bugs in the language.

* * *

Side note: are you able to access [bugs.swift.org](http://bugs.swift.org)? For me, the website is unavailable (it's giving me a 503 error since Saturday).

---

<div class="post-metadata">

**Author:** ![ensan-hcl](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ensan-hcl/32/15186_2.png) [@ensan-hcl](https://forums.swift.org/u/ensan-hcl)\
**Post date:** [May 24, 2021, 4:00am UTC](https://forums.swift.org/t/how-to-use-pattern-match-for-overloaded-enum/48768/3 "2021-05-24T04:00:36Z")

</div>

Thank you for reply, I didn't know how that happened. I'll read proposals and threads!

* * *

> [@xAlien95](#):
>
> Side note: are you able to access [bugs.swift.org](http://bugs.swift.org)? For me, the website is unavailable (it's giving me a 503 error since Saturday).

I can't access it either 😢

---

<div class="post-metadata">

**Author:** ![typesanitizer](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/typesanitizer/32/8661_2.png) [@typesanitizer](https://forums.swift.org/u/typesanitizer)\
**Post date:** [May 24, 2021, 3:17pm UTC](https://forums.swift.org/t/how-to-use-pattern-match-for-overloaded-enum/48768/4 "2021-05-24T15:17:51Z")

</div>

As Stefano pointed out, this feature hasn't been fully implemented. I've created [[SR-14638] ☂️ Full support for overloaded enum cases (SE-0155) · Issue #56990 · apple/swift · GitHub](https://bugs.swift.org/browse/SR-14638) to collect bugs related to this.
