-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix UnusedLetBind: account for inherit
#62
base: master
Are you sure you want to change the base?
Conversation
How does this affect performance? Is this still able to check all of nixpkgs in a reasonable time? |
Some basic testing suggests this is somewhat cpu intensive, but not extremely so: Before:
After:
|
Ah I see. I have a few ideas for considerably speeding up the execution.
Cons:
Up to you which you prefer |
One thing that would help me is understanding where the function EDIT: I remembered that |
I think I copied that from hnix back when they didn't export it (around hnix 0.4 or so). It would probably be better to use the upstream version if they export it, and do any bugfixes there instead of copying it. |
Alright, let me know what you think of this solution. It doesn't copy over all the code, just the stuff that's needed to make the function we want. Also let me know if it actually speeds anything up. I'm getting wildly inconsistent speeds from one run to the next, so I can't easily compare. |
This fixes #61 and additionally checks
inherit
statements for unused identifiers bound.It changes the philosophy of checking for unused let bindings a little bit. Now it checks by removing each binding in turn and reconstructing the rest of the
let
statement, and then checking whether that name is free in the constructed let binding. If not, it wasn't being used.For instance,
Becomes internally
and now
x
is free, so we were using that binding. It also becomesand now
y
is free, so we needed that binding too. Finally, it becomesAnd we discover that
z
is not free, so the last binding was not needed. If theinherit
binds multiple values, it will check each of them separately.