In this code, the compiler knows that the else branch never make it beyond the throw, so it doesn't complain that there's no value to assign to foo in the else branch. I would like to have a custom function which does throw, but first does some other things, and call that function in the else case