ndmitchell / ndmitchell/hlint

HLint doesn't understand that identifiers with the same name can have different types and values, which can introduce subtle runtime bugs

Open
#883 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
1.6k
Forks
210
PR merge metrics
No merged PRs in 30d

Description

Consider this program:

import Data.Maybe (isJust)

threeTenths :: RealFrac a => Maybe a
threeTenths = if 1/10 + 1/5 == correctAnswer then Just correctAnswer else Nothing
  where correctAnswer = 3/10

main :: IO ()
main = print $ isJust (fmap fromRational threeTenths)

It prints True. Running hlint on it will suggest using isJust threeTenths instead of isJust (fmap fromRational threeTenths). However, implementing that suggestion will cause it to instead print False.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Haskell reproducer in the issue and inspect the HLint suggestion that replaces isJust (fmap fromRational threeTenths) with isJust threeTenths. Determine where this suggestion is generated and verify that the fix does not change the program's result; done means this unsafe suggestion is no longer produced and the reproducer is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.