From a language point of view, an unreachable statement is not an error, as the code is not executed. This is bad style at best.
However, surprisingly, in Nit it was en error because adaptive typing use the flow graph to compute the static type of variables and expression. Having unreachable code make the static type of those more complex to report to the user in a stable manner.
From a software engineering point of view, having a warning let the user shortcuts method when debugging. This is anyway cleaner than using opaque predicates à la if true then return that do not cause a warning (maybe it should, but it is another issue).
This, this PR tries to do the right thing by making unreachable statements a warning. The static type of things is however just let as is without additional type adaptation, undefined variable are also silenced.
From a language point of view, an unreachable statement is not an error, as the code is not executed. This is bad style at best.
However, surprisingly, in Nit it was en error because adaptive typing use the flow graph to compute the static type of variables and expression. Having unreachable code make the static type of those more complex to report to the user in a stable manner.
From a software engineering point of view, having a warning let the user shortcuts method when debugging. This is anyway cleaner than using opaque predicates à la
if true then return
that do not cause a warning (maybe it should, but it is another issue).This, this PR tries to do the right thing by making unreachable statements a warning. The static type of things is however just let as is without additional type adaptation, undefined variable are also silenced.