I suspect typed throws
will eventually want some sort of union capability, but I would hope that it'd have the form of a "type function" — a type expression that evaluates to a type by some simple rule — rather than a general anonymous-sum feature. That is, you ought to be able to throw union(E, IOError)
, and that type will resolve to IOError
if E
is Never
or IOError
but fall back to Error
if E
is anything else. That fallback rule avoids the general pitfalls of these anonymous union types but also make it very special-case around errors.
10 Likes