3.5 Unions and optionals
A | B— an anonymous union. Unions are flat (A | (B | C)=A | B | C), the order does not matter, duplicates are removed.- Subtyping:
Ais a subtype ofA | B; a value of a subtype is implicitly converted to the union. T?is shorthand forT | none.- Type narrowing:
x is Tin a condition,match,?,??,?.,!(§5, §6.5). Afterif x is Tthe variablexhas typeTin the branch if it is immutable or was not modified in the branch. - A union that contains at least one type with
@error(§6.5) is a result with an error; it cannot be ignored.
Related diagnostics
See also
Source: docs/spec/oxl-standard.en.md