If we need union types for error handling, could we introduce this as general-purpose support that supports any types? (e.g. support for any union types like Int | String
, including T | Error
)
The Commonly Rejected Changes list seems to mention union types:
- Disjunctions (logical ORs) in type constraints: These include anonymous union-like types (e.g.
(Int | String)
for a type that can be inhabited by either an integer or a string). "[This type of constraint is] something that the type system cannot and should not support."
Type unions have always seemed like a broadly useful idea to me, and I'm not familiar with the background/context around prior discussions. T | Error
seems like a natural and precedented spelling for a feature like this (that could be broadly useful outside of error handling).