haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

List comprehensions are treated as quasiquotes

Open TheBFL opened this issue 2 years ago • 8 comments

Your environment

Which OS do you use?

  • WSL 2 (Ubuntu)

Which version of GHC do you use and how did you install it?

  • 9.0.2 ghcup

Which LSP client (editor/plugin) do you use?

  • VSCode/Haskell

Which version of HLS do you use and how did you install it?

  • 1.7.0.0 from ghcup.

Have you configured HLS in any way (especially: a hie.yaml file)?

  • No.

Steps to reproduce

Create a haskell file in vscode, with the contents:

main = print [x| x <- [1..10]]

the same behavior occurs even when {-#LANGUAGE NoQuasiQuotes#-} is added.

Expected behaviour

HLS treats this as a list comprehension, and displays the appropriate suggestions (such as "redundant list comprehension"), when quasiquotes are disabled.

Actual behaviour

HLS gives an error when there is no space before the | in the list comprehension, claiming that it is an unterminated quasiquotation at end of input when QuasiQuotes are not enabled.

TheBFL avatar Aug 23 '22 15:08 TheBFL

Interesting... Appears to be 9.0.2 specific. Can't reproduce on 8.10.7 nor 9.2.4 using master branch.

drsooch avatar Aug 23 '22 15:08 drsooch

Same here in MacOS 12.15.1

arademaker avatar Aug 23 '22 16:08 arademaker

Hmm, this seems like it could be us somehow enabling QuasiQuotes unconditionally, but I can't see how that would happen.

michaelpj avatar Aug 25 '22 14:08 michaelpj

I tried this, and the exceptionally weird thing is that if the appropriate end of the quasiquotation is added, like so:

main = print [x| x <- [1..10]|]

then HLS gives a Quasi-quotes are not permitted without QuasiQuotes error. So it's not like they're just automatically enabled from what I can tell

TheBFL avatar Aug 25 '22 14:08 TheBFL

HLS parses in a slightly unconventional mode since it enables -haddock. Can you repro just with ghc -haddock Foo.hs?

pepeiborra avatar Aug 26 '22 15:08 pepeiborra

ghc -haddock BugTest.hs compiles properly, and doesn't give any error about quasiquotes. Seems the issue is specific to HLS.

TheBFL avatar Aug 26 '22 16:08 TheBFL

I think this is triggered by hlint. I can't reproduce this with just ghcide.

wz1000 avatar Sep 07 '22 11:09 wz1000

Is this still a problem?

michaelpj avatar Jan 16 '24 18:01 michaelpj