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

Why isn't all the code after a return statement removed? #93

Open
nbro opened this issue Aug 6, 2021 · 0 comments
Open

Why isn't all the code after a return statement removed? #93

nbro opened this issue Aug 6, 2021 · 0 comments

Comments

@nbro
Copy link

nbro commented Aug 6, 2021

Let's say we have this function

def my_func(x):
    a = 0
    return x  # Code after this is dead code!
    return x

Then your tool (i.e. by calling fix_code) does not remove the second return x, but produces

def my_func(x):
    return x  # Code after this is dead code!
    return x

In general, all the code after the last return statement that we know will be executed is not executed, so it's dead code that can be removed. So, why doesn't your tool handle these cases?

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

No branches or pull requests

1 participant