Switch expressions spec

Guy Steele guy.steele at oracle.com
Sat Mar 16 00:01:21 UTC 2019

And here’s another way to think about it: if a subexpression never completes normally, then in effect there is unreachable code in the containing expression, and we don’t like to have unreachable code.

> On Mar 15, 2019, at 3:09 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> At the same time, we also reaffirmed our choice to _not_ allow throw from one half of a conditional:
>    int x = foo ? 3 : throw new FooException()
> But John has this right — the high order bit is that every expression should have a defined normal completion, and a type, even if computing sub-expressions (or in this case, sub-statements) might throw.  And without at least one arm yielding a value, it would be impossible to infer the type of the expression.  

More information about the amber-spec-observers mailing list