rikvdkleij / intellij-haskell

IntelliJ plugin for Haskell
https://rikvdkleij.github.io/intellij-haskell/
Apache License 2.0
1.31k stars 94 forks source link

Syntax highliting error with missing space in list comprehension #528

Closed Adrijaned closed 4 years ago

Adrijaned commented 4 years ago

When doing Screenshot_20200324_120446 , everything works as expected. However, if I for whatever reason miss the space in before the first pipe, this happens: Screenshot_20200324_120559 Please note that the dark yellow continues until the very end of file, no matter what is after it. Code compiles and behives as expected in both cases.

rikvdkleij commented 4 years ago

Thanks for reporting!

Which version of the plugin?

rikvdkleij commented 4 years ago

@Adrijaned Ok, I can reproduce this issue in latest beta.

rikvdkleij commented 4 years ago

It's because the parser sees your second case as quasi quotation and that's right when the QuasiQuotes language extension is enabled...

rikvdkleij commented 4 years ago

I don't know how to fix this issue.

Adrijaned commented 4 years ago

Ooof, sorry for not getting to you earlier with the plugin version, only just got to PC. I'm only a beginner haskeller, but my quick google search revealed that quasiquotations have always the following syntax: [ident|..|]. Would it be possible to issue something like warning, prefferably at the line where the quasiquote is started, saying "A QuasiQuotation expression was started, but never ended", if the matching |] cannot be found until the end of file? An intent inserting the missing space for the warning along the lines of "Did you mean to write list comprehension?" would be appreciated too.

rikvdkleij commented 4 years ago

saying "A QuasiQuotation expression was started, but never ended

Yep, after some more digging, to get that behavior I have to move the quasi quotes element from the lexer to the bnf but that’s a risky change... but will try it.

rikvdkleij commented 4 years ago

I don't succeed in finding a proper solution for this issue. Each alternative solution I found had bigger issues than this issue.

@ice1000 Can you help?

ice1000 commented 4 years ago

Random guess: access language extensions in the lexer

rikvdkleij commented 4 years ago

It’s not about language extensions, it’s about the quasi quote extension syntax which starts similar as a for comprehension. In don’t see a way in the QQ definition of the lexer to go back when there in no |] at the end.

rikvdkleij commented 4 years ago

Should be fixed in beta69.

rikvdkleij commented 4 years ago

Please reopen if still an issue.