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

Multiple levels of eta-reduction as a single suggestion #6

Open
danth opened this issue Oct 28, 2021 · 2 comments
Open

Multiple levels of eta-reduction as a single suggestion #6

danth opened this issue Oct 28, 2021 · 2 comments

Comments

@danth
Copy link
Contributor

danth commented Oct 28, 2021

I came across this case while testing #5:

[W07] Warning: This function expression is eta reducible
    ╭─[/tmp/test.nix:10:16]
    │
 10 │   test7 = arg: otherArg: function arg otherArg;
    ·                ───────────────┬───────────────  
    ·                               ╰───────────────── Found eta-reduction: function arg
────╯

After applying the suggestion above, I get a new suggestion to eta-reduce test7 further:

[W07] Warning: This function expression is eta reducible
    ╭─[/tmp/test.nix:10:11]
    │
 11 │   test7 = arg: function arg;
    ·           ────────┬────────  
    ·                   ╰────────── Found eta-reduction: function
────╯

Ideally, Statix would produce a single suggestion like:

[W07] Warning: This function expression is eta reducible
    ╭─[/tmp/test.nix:10:11]
    │
 10 │   test7 = arg: otherArg: function arg otherArg;
    ·           ────────────────────┬───────────────  
    ·                               ╰───────────────── Found eta-reduction: function
────╯
@oppiliappan
Copy link
Owner

Hmm, this is a tall ask 😅. I think it partly requires rethinking how the whole lint framework behaves altogether. Currently lints are expected to be as "local" as possible. When the lint runner approaches the node beginning at otherArg it has to somehow know that otherArg: function arg otherArg is not supposed to be linted because it was already linted as a part of arg: otherArg: function arg otherArg. This partly helps fixes also to be "local" and easy to reason about. At the moment, I can't quite think of a way to implement this.

statix fix is able to fix the this issue in one blow however (a single run, but multiple passes over the source).

@danth
Copy link
Contributor Author

danth commented Oct 28, 2021

Further to that, we can't simply skip linting of otherArg: function arg otherArg as it could be a more complex expression containing other suggestions.

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

2 participants