On Tuesday, 28 June 2016 at 13:34:48 UTC, QAston wrote:
On Monday, 27 June 2016 at 22:56:41 UTC, Jonathan M Davis wrote:
Agreed. The code outside of the static if should be compiled
regardless, because it's not part of the static if/else at all
and therefore has not been marked as conditionally compilable.
But if we don't warn about unreachable code, then the code
after the static if can clearly be optimized out because it's
unreachable. So, Andrei's code would become legal as long as
the only problem with the code after the static if was that it
was unreachable.
- Jonathan M Davis
The "allow unreachable code" solution has it's own limitations
compared to implicit-else-block. It doesn't allow varying
return type and differing declarations in the two blocks.
"The solution doesn't solve all problems, therefore the solution
do not make things any better"
Nonsense.
Allowing unreachable code also shares readibility problems
(because the example code is exactly the same for both
solutions), although it's conceptually easier to understand and
more consistent, so it's prefered.
We already allow unreachable code in various places for
convenience reasons (or because the control flow analysis is
fubared ?). Anyway, considered nobody complained about these
cases ever, it is fair to assume that this is not a big deal.