Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make 'Unreachable statement' a warning #2838

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

privat
Copy link
Member

@privat privat commented Jun 27, 2024

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.

@privat privat closed this Jun 27, 2024
@privat privat reopened this Jun 27, 2024
Copy link

Test Results

    67 files     338 suites   16m 46s ⏱️
14 184 tests 13 643 ✅ 541 💤 0 ❌
14 810 runs  14 222 ✅ 588 💤 0 ❌

Results for commit 43e7884.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant