It is currently impossible to properly assign two or more distinct tagged unions

I am not using the new type solver. I’m not sure if this is an issue with the new solver.

Tagged unions are a little funky, since they only work as expected if both types are singletons, and not the product of a union or intersection. This is a workaround for the intersection between a base type and a tagged union:

type foo = {tag: "foo", foo: boolean}
type bar = {tag: "bar", bar: boolean}
type something = foo | bar --> works as expected

type frob = {frob: boolean}
type doesntWork = frob & something --> doesn't apply the type correctly

-->> workaround
type doesWork = (foo & frob) | (bar & frob)

However, if you want to assign two or more distinct tagged unions in one type, this all falls apart.

type foo = {tag: "foo", foo: boolean}
type bar = {tag: "bar", bar: boolean}

type butterfly = {animal: "butterfly", lift: number}
type horse = {animal: "horse", speed: number}

type someBaseType = {name: string}

-->> doesn't work
type doubleUnion = someBaseType & (foo | bar) & (butterfly | horse)

local example: doubleUnion = {}
if example.animal == "butterfly" then
    print(example.lift) --> warns that "lift" doesn't exist
end