Hints fail to alpha-convert new variables if necessary
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 1.6k
- Forks
- 210
- PR merge metrics
- No merged PRs in 30d
Description
Consider these hints:
- warn: {lhs: zipWith f y (repeat z), rhs: map (\x -> f x z) y}
- warn: {lhs: zip (map f x) x, rhs: "map (\\y -> (f y, y)) x"}
Both of them bind a new variable in the RHS, and refer to a variable from the LHS in the same scope. HLint will blindly use the variable name from the hint as-is, even if it needs to be alpha-converted to be correct. This will result in HLint incorrectly suggesting that zipWith f xs (repeat x) be replaced with map (\x -> f x x) xs, and that zip (map y xs) xs be replaced with map (\y -> (y y, y)) xs. It should instead suggest, e.g., map (\x_ -> f x_ x) xs and map (\y_ -> (y y_, y_)) xs (which is similar to what it does in some other circumstances, such as #1132, when it automatically converts an infix section to a lambda). I worked around this for the first given hint in #1131, and the merge of #1178 is currently blocked due to this.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the two YAML hint examples and trace HLint's hint application and variable-renaming behavior. Review the related context in issues #1131, #1178, and #1132; done means generated replacements alpha-convert bound variables when needed and avoid capturing variables from the left-hand side.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100