This seems like a glaring flaw in the runtime, and prevents TaggedUnion<A, B, ...> and Union<A, B, ...>. Unfortunately, this restriction occurs as a runtime error, so I was not aware of it until now.
While it's technically possible to get around this using our Bytes API and a fixed-size byte array, this incurs both a marshaling cost as well as the necessity of a heap allocation, which ruins the point of a Union.
For that reason, it's probably worthwhile to remove the Union struct for now, at least until a reasonable implementation can be found. If you have a way to inline a byte array of potentially varying size into a struct, please let me know.
In the meantime, Union and TaggedUnion will remain broken, until they are removed or fixed.
This seems like a glaring flaw in the runtime, and prevents
TaggedUnion<A, B, ...>andUnion<A, B, ...>. Unfortunately, this restriction occurs as a runtime error, so I was not aware of it until now.While it's technically possible to get around this using our
BytesAPI and a fixed-size byte array, this incurs both a marshaling cost as well as the necessity of a heap allocation, which ruins the point of a Union.For that reason, it's probably worthwhile to remove the Union struct for now, at least until a reasonable implementation can be found. If you have a way to inline a byte array of potentially varying size into a struct, please let me know.
In the meantime,
UnionandTaggedUnionwill remain broken, until they are removed or fixed.