union types

A KDLScript union type is a C-like untagged union. For rust-like tagged unions, see tagged types.

This definition:

union "FloatOrInt" {
    a "f32"
    b "u32"
}

is equivalent to this Rust:

#![allow(unused)]
fn main() {
union FloatOrInt {
    a: f32,
    b: u32,
}
}

and this C:

typedef union FloatOrInt {
    float a;
    int32_t b;
} FloatOrInt;