# Pattern matching + Enum proposals

**URL:** <https://forum.modular.com/t/pattern-matching-enum-proposals/3473>\
**Category:** Language Design\
**Tags:** discussion\
**Created:** [September 7, 2026, 2:54am UTC](https://forum.modular.com/t/pattern-matching-enum-proposals/3473 "2026-09-07T02:54:29Z")\
**Posts on this page:** 1\
**Showing post:** 27

<div class="post-metadata">

**Author:** ![Nick](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/nick/32/1437_2.png) [@Nick](https://forum.modular.com/u/Nick)\
**Post date:** [September 9, 2026, 10:28pm UTC](https://forum.modular.com/t/pattern-matching-enum-proposals/3473/27 "2026-09-09T22:28:38Z")

</div>

> It seems that `comptime` declarations and a single `Variant` type cannot provide this.

I don’t see any roadblocks. Here’s what I’d write, once [struct extensions](https://forum.modular.com/t/struct-extensions-proposal/2145) are implemented:

```auto
# Declares Color as an alias for Variant[Red, Green, Blue]
comptime Color = struct Red | struct Green | struct Blue

extension Color(Defaultable):
    def __init__ (out self):
        self = Self(Red()) # delegates to Variant. __init__

```

This struct extension on `Variant` will be valid (i.e. satisfy the coherence rules) as long as Mojo adopts rules similar to those of Carbon. I posted info about Carbon’s rules [here](https://forum.modular.com/t/struct-extensions-proposal/2145/28). (They were explained in a talk.)

Regarding alignment (`@align`): I’m not sure how it is modelled today, but I could imagine it also boiling down to a trait implementation.

---

_[View the full topic](https://forum.modular.com/t/pattern-matching-enum-proposals/3473)._
