ndmitchell / ndmitchell/hlint

Aliasing records pattern matching break if space exists

Open
#486 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This snippet is parsed successfully:

data X = X {unX :: Int, unY :: Bool}
foo :: X -> Bool
foo x@X{unY = bb} = True

But after adding spaces:

data X = X {unX :: Int, unY :: Bool}
foo :: X -> Bool
foo x @ X{unY = bb} = True

I get '[hlint] Parse error'

I'm using haskell-ide-engine in vs code
Version: PS D:\dev\pandoc> hlint --version HLint v2.1, (C) Neil Mitchell 2006-2018

If I run hlint from command line, I don't see this warning...

hlint .\src\Text\Pandoc\Readers\Man.hs
.\src\Text\Pandoc\Readers\Man.hs:47:1: Suggestion: Unnecessary hiding
Found:
  ?[32;4mimport?[0m?[0m ?[0m?[0mText?[0m?[36m.?[0m?[0mPandoc?[0m?[36m.?[0m?[0mParsing?[0m?[0m ?[0m?[0mhiding?[0m?[0m ?[0m?[36m(?[0m?[0menclosed?[0m?[36m)?[0m
Why not:
  ?[32;4mimport?[0m?[0m ?[0m?[0mText?[0m?[36m.?[0m?[0mPandoc?[0m?[36m.?[0m?[0mParsing?[0m

.\src\Text\Pandoc\Readers\Man.hs:75:49: Warning: Redundant bracket
Found:
  ?[36m(?[0m?[0mManState?[0m?[36m{?[0m?[0mpState?[0m?[0m ?[0m?[31m=?[0m?[0m ?[0m?[0mdef?[0m?[36m,?[0m?[0m ?[0m?[0mrState?[0m?[0m ?[0m?[31m=?[0m?[0m ?[0m?[0mdef?[0m?[36m}?[0m?[36m)?[0m
Why not:
  ?[0mManState?[0m?[36m{?[0m?[0mpState?[0m?[0m ?[0m?[31m=?[0m?[0m ?[0m?[0mdef?[0m?[36m,?[0m?[0m ?[0m?[0mrState?[0m?[0m ?[0m?[31m=?[0m?[0m ?[0m?[0mdef?[0m?[36m}?[0m

.\src\Text\Pandoc\Readers\Man.hs:79:13: Suggestion: Move brackets to avoid $
Found:
  ?[35m"Pandoc: "?[0m?[0m ?[0m?[36m++?[0m?[0m ?[0m?[36m(?[0m?[0mshow?[0m?[0m ?[0m?[36m$?[0m?[0m ?[0m?[0munMeta?[0m?[0m ?[0m?[0mm?[0m?[36m)?[0m
Why not:
  ?[35m"Pandoc: "?[0m?[0m ?[0m?[36m++?[0m?[0m ?[0m?[0mshow?[0m?[0m ?[0m?[36m(?[0m?[0munMeta?[0m?[0m ?[0m?[0mm?[0m?[36m)?[0m

.\src\Text\Pandoc\Readers\Man.hs:115:20: Suggestion: Use unwords
Found:
  ?[34mconcat?[0m?[0m ?[0m?[36m$?[0m?[0m ?[0m?[0mintersperse?[0m?[0m ?[0m?[35m" "?[0m?[0m ?[0m?[0margs?[0m
Why not:
  ?[34munwords?[0m?[0m ?[0m?[0margs?[0m

.\src\Text\Pandoc\Readers\Man.hs:146:29: Suggestion: Use void
Found:
  ?[34mmodifyRoffState?[0m?[0m ?[0m?[36m(?[0m?[31m\?[0m?[0m ?[0m?[0mrst?[0m?[0m ?[0m?[31m->?[0m?[0m ?[0m?[0mrst?[0m?[36m{?[0m?[0minCodeBlock?[0m?[0m ?[0m?[31m=?[0m?[0m ?[0m?[0minsideCB?[0m?[36m}?[0m?[36m)?[0m?[0m ?[0m?[36m>>?[0m?[0m ?[0m?[0mreturn?[0m?[0m ?[0m?[0m()?[0m
Why not:
  ?[0mControl?[0m?[36m.?[0m?[0mMonad?[0m?[36m.?[0m?[0mvoid?[0m?[0m
  ?[0m?[0m  ?[0m?[36m(?[0m?[0mmodifyRoffState?[0m?[0m ?[0m?[36m(?[0m?[31m\?[0m?[0m ?[0m?[0mrst?[0m?[0m ?[0m?[31m->?[0m?[0m ?[0m?[0mrst?[0m?[36m{?[0m?[0minCodeBlock?[0m?[0m ?[0m?[31m=?[0m?[0m ?[0m?[0minsideCB?[0m?[36m}?[0m?[36m)?[0m?[36m)?[0m

.\src\Text\Pandoc\Readers\Man.hs:180:28: Suggestion: Redundant bracket
Found:
  ?[0mString?[0m?[0m ?[0m?[31m->?[0m?[0m ?[0m?[36m(?[0m?[0mMaybe?[0m?[0m ?[0m?[0mInline?[0m?[36m)?[0m
Why not:
  ?[0mString?[0m?[0m ?[0m?[31m->?[0m?[0m ?[0m?[0mMaybe?[0m?[0m ?[0m?[0mInline?[0m

6 hints

But I see unix-terminal special ascii charcters, which are not supported by powershell

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 by reproducing the two alias-pattern snippets with HLint v2.1 and compare the parser behavior for the versions with and without spaces. The issue names no source file or test; done means the spaced pattern parses without a parse error while the existing command-line hints continue to work.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.