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

Invalid hint for record field id #1383

Open
t4ccer opened this issue Jun 2, 2022 · 4 comments
Open

Invalid hint for record field id #1383

t4ccer opened this issue Jun 2, 2022 · 4 comments

Comments

@t4ccer
Copy link

t4ccer commented Jun 2, 2022

When using OverloadedRecordDot extension after defining record with field name id, hlint will give incorrect hints when field id of record is used via dot syntax.

Example

data Foo = Foo
  { id :: Int
  }

main = do
  let x = Foo 42
  print x.id

Actual

hlint src/Lib.hs:

src/Lib.hs:9:3-12: Warning: Redundant id
Found:
  print x . id
Perhaps:
  print x

Expected

No hints found on print x.id line

Setup

GHC: 9.2.1
hlint: v3.4/052eff7 (master branch as of today)

Potential solution

Enabling ghc-lib solves the issue, #1376 will solve it

@ndmitchell
Copy link
Owner

Thanks - as it stands HLint doesn't know about the OverloadedRecordDot extension, so thinks you have written a function composition. Given #1376 is incoming, let's wait and then once that lands, write a test for this so it doesn't happen again.

@svobot
Copy link

svobot commented Jan 25, 2023

I don't know if this is useful, but another example that I've encountered is the following:

data Foo = Foo
  { id :: Int
  }

main = print $ (Foo 42).id

Results in:

Suggestion: Redundant bracket
Found:
  (Foo 42) . id
Perhaps:
  Foo 42 . id

@StevenXL
Copy link

@ndmitchell thank you very much for this library. I was having the issue as well, but it turned out it was because OverloadedRecordSyntax was not enabled at the (at the package or module level). Once that was enabled, things work.

TLDR, should this issue be closed?

hlint --version => HLint v3.5, (C) Neil Mitchell 2006-2022.

@sirrus233
Copy link

I still get this issue on HLint v3.8, is there remaining work that needs to be done here? Or might there have been a regression?

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

5 participants