On Tuesday, 27 June 2017 at 11:40:02 UTC, Moritz Maxeiner wrote:
It's not at all bad code to write things down that the
compiler could infer, quite the opposite.
Of course it is bad, because the compiler can do it better (no
chance for a wrong exception set sans compiler bugs) and faster
than you.
Writing it down signals _intent_ and the compiler can check if
the implementation is matching the specification
Verifying that a function meets its specification is what
unittests are for (asserts for runtime behaviour, static
asserts for types).
You might as well argue that you shouldn't have to declare the
return type of functions because the compiler can determine that
automatically based on the types of values you are actually
returning. Then write unit tests to make sure that the return
type as determined by the compiler matches what you intended.