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.go...@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.  

Reply via email to