Expand fn literals at threading macroexpand time #2282
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have read the Clojure etiquette and will respect it when communicating on this platform.
I have read the developer documentation.
This PR corresponds to an issue with a clear problem statement. (1923)
This PR contains a test to prevent against future regressions
I have updated the CHANGELOG.md file with a description of the addressed issue.
This PR takes the functionality from #2211 which wasn't implemented in #2243.
Namely the work to thread into fn literals (
#()
forms) so invalid names and unused values can be detected.Before this PR, the following code would not raise a linting error:
But after it, it raises a "Function name must be simple symbol but got: :foo" error.
This makes sense because the macroexpansion of the above form looks like so:
Also, before this PR, the following code would not raise a linting error:
But after it, it raises an "Unused value" error.
This makes sense because the macroexpansion of the above form looks like so:
The PR is split into two commits, which should be squashed:
This is the functional changes:
a. Add separate treatment for
:fn
forms vs other non-lists inexpand->
andexpand->>
b. Move
%
anaphoric argument handling earlier inanalyze-fn
c. Add
fn*
to the list of core-syms checked byanalyze-usages2
andlint-var-usage
(as this is what fn literals expand to)I think it's clearer to move the
expand-fn
code and its dependencies as a separate step, to show that nothing in it is changed. Added tests & updated the changelog.