-
Notifications
You must be signed in to change notification settings - Fork 571
Unused var tweaks #4088
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
Unused var tweaks #4088
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
src/Language/PureScript/Linter.hs
Outdated
removeAndWarn ss newNames (used, errors) = | ||
let filteredUsed = used `S.difference` newNames | ||
removeAndWarn :: SourceSpan -> S.Set (SourceSpan, Ident) -> (S.Set Ident, MultipleErrors) -> (S.Set Ident, MultipleErrors) | ||
removeAndWarn _ newNamesWithSpans (used, errors) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why keep the _
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I have a short attention span?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh there is so much noise floating around due to this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some cosmetic fixes and then LGTM.
src/Language/PureScript/Linter.hs
Outdated
allExprs = concatMap unguard gexprs | ||
in | ||
removeAndWarn ss bindNewNames $ mconcat $ map (go ss) allExprs | ||
removeAndWarn bindNewNames $ mconcat $ map (go) allExprs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unneeded parens in (go)
. (I found four of these in total; they're easy to search for.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh dear, a little bit naive on the search and replace :)
src/Language/PureScript/Linter.hs
Outdated
in removeAndWarn letNewNamesRec $ | ||
mconcat (map underDecl ds) | ||
<> removeAndWarn letNewNames (doElts rest v) | ||
doElts (PositionedDoNotationElement _ _ e : rest) v = doElts (e : rest) v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space in the RHS here.
Oh sorry, would you add a CHANGELOG.md entry for this too? |
Improvements to unused variable lint/warnings.
Fix a bad unused variable warning (fix #4083). The previous iteration was not distinguishing between variables bound recursively within the let binding, and those that are only bound inside the body.
Unchanged with this commit is that identifiers which are used recursively within a let binding will count as used (ie not warn), despite the fact that the binding could be removed - something more intelligent would be required to handle mutually recursive let blocks which may or may not be used externally.
Tighten the warning spans on unused variables (fix #4087).
This will scope to the identifier itself for binders, but a value declaration
let x = e in e2
will scope to the entirex = e
asValueDecl
does not have a source span for the identifier alone.Checklist: