This looks mostly fine to me. I'd rather these be called `union` but it's a minor complaint.
The distinction between mutable and immutable bindings seems irrelevant. Why not have mutability follow the mutability of the matched-upon object? I would much prefer to do away with `let`, `var`, and `as` and just have ex. `of BinaryOpr(a, UnaryOpr(b)) if a == b` but understand it breaks existing `case` semantics... I would suggest also overloading `of` to function in `while` statements: var optional = Some(0) if optional of Some as i: echo "optional is inhabited!" while optional of Some as i: # optional of Some(var i): if i > 9: echo "Greater than 9, quit!" optional = None else: echo fmt"`i` is `{i}`. Try again." optional = Some(i + 1) Run The complex / structural pattern matching looks nice, and could be implemented later for the sake of getting this in the language quickly (or as a macro! possibly). It would probably have to reject inconsistent bindings to work with the way matching multiple enum variants at once currently works: case foo # rejected! there is not a binding b in all branches: of BinaryOpr(var a, UnaryOpr(let b)), UnaryOpr(var a) if a == b` # allowed! both a and b's types are consistent: of BinaryOpr(var a, UnaryOpr(let b)), BinaryOpr(var a, let b) if a == b: discard Run