OxL Reference

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: A is a subtype of A | B; a value of a subtype is implicitly converted to the union.
  • T? is shorthand for T | none.
  • Type narrowing: x is T in a condition, match, ?, ??, ?., ! (§5, §6.5). After if x is T the variable x has type T in 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.

type-mismatch

See also

Source: docs/spec/oxl-standard.en.md