-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Parse error on comment that ghc accepts #909
Comments
I don't think this will stop the IDE working. In fact you can see in your log that In fact I think the bug report here is that parse errors reported when parsing with |
Indeed, you're right. I just saw my editor flaring up with red together with a parse error and automatically assumed the the IDE wouldn't work 😄 |
I just discovered this as well. (And fwiw, I think this should not be reported at all, not even as a warning. I don't want a correct program to suddenly have errors or warnings in my IDE.) |
@kosmikus if you ever want to run haddock on this file it will fail. That seems like something that definitely should be fixed (ideally in Haddock, to not fail, but in the absence of that, in all programs) |
Perhaps |
Is this a bug or a feature? ghcide parses Haddock comments in your project to display them in hovers, so it's only reasonable that it shows an error if a Haddock comment doesn't parse. I can see how this can be surprising if you were not intending to write a Haddock comment at all! But (to me) this seems like a minor inconvenience. We could very easily turn this error into a warning, but then we would get bug reports of the form "ghcide displays Haddocks for all my modules except Foo". So I'm not keen on doing that, but I'm not opposed either. |
FWIW, I really like this feature as an IDE user and I have now started writing a lot more haddock comments than before as they become immediately useful. It should probably be just a warning rather than an error though. |
I hate configuration options as they turn into a support nightmare. For every bug, you have to get the users config. You have to document it. And the number of users who configure something is tiny, so the benefit is low. I think these should definitely be warnings. Warnings mean your code runs, but something undesirable - and there that "something undesirable" is no docs. I think it gets very confusing for people when warnings don't mean there code doesn't run - I did that with HLint for a while and it just confused everyone calling the suggestions errors. |
Normally, I can turn off warnings that I don't want in GHC. With this one, I take it that it would not be possible to turn off. I think that's really bad. I think it's a case where ghcide is unfortunately trying to do too much, and less is more. The expectation that a file that's fine for GHC should be fine for ghcide sounds reasonable to me. |
And just to illustrate: the situation where I'm encountering this is commenting out a line with a guard. I find it completely natural during development to do that, even if this may not end up being "final" code. I find bogus warnings / errors for something like this very distracting. |
Andres, you make a good case about the inconvenience of the current situation, but I'm confused by your other comments, in particular the less is more one. Are you saying that ghcide is going too far by displaying Haddocks in the current project? |
I think this comment is from a perspective where I originally thought ghcide was deliberately trying to do only few things, and do them well, and lots of more involved features would be part of haskell-language-server. Personally, I would indeed prefer if ghcide would focus on GHC and nothing else (no hlint, no haddock, no ...). That problem space seems difficult enough. But I am sorry, I should not have generalised so much, and I should not have mixed it up with this issue, and it is not my place to question the overall direction of ghcide which in principle I enjoy using very much. |
Your perspective is correct, its just that Haddocks fall inside the GHC sphere because they are produced by Parsing and embedded into interface files. @wz1000 @mpickering have you by any chance already addressed this issue in hls and want to upstream the fix to ghcide? |
I see. If this is actually produced by GHC, is there a flag I can add to the ghc-options of my cabal file that triggers these errors also during normal compilation then, so that I could at least re-establish consistency of behaviour in the other direction? |
Yes, it's the |
My 2 cents (in case anyone cares 😄) Flag vs warning vs errorI agree that adding a flag for such a thing seems overkill, and not worth the cost (maintenance, bug tracking, documentation, etc.). I personally don't mind if it is displayed as an error, but I understand some concerns/inconveniences, so displaying as a warning would be fair, too. If I had to pick, I would keep it as an error: I prefer not to write or read code that will not be able to display documentation, it looks like a code smell to me Error messageThat being said, I think the error message should be improved. I met this issue a couple of days ago (and opened an issue to HLS) and it never occurred to me the problem was related to Haddock. Notice that in @googleson78 original post, there is no mention of Haddock whatsoever. And Ghcide never mentions it either. Had I been informed it could not be parsed by Haddock, I would have solved this problem in seconds. At least when running $ stack haddock
# Much noise...
Running Haddock on library for foobar-0.1.0.0..
src/Lib.hs:9:3: error: parse error on input ‘-- $’
|
9 | -- $
| ^^^^
Haddock coverage: |
As someone who made the mistake of classifying non-errors using the error word in HLint, we really want this to be a warning and not an error. Errors stop your code from running. People get super confused if their code runs and has an error. Super confused people raise issues. Issues need to be replied to. It's a shame that upstream GHC doesn't include the word Haddock parser error, but I guess that means we have to munge it ourselves. |
Patch in haskell/ghcide#608. |
* #573, make haddock errors warnings with the word Haddock in front * Update Rules.hs * Deal with Haddock failures in getModIfaceRule
…k in front (haskell/ghcide#608) * haskell/ghcide#573, make haddock errors warnings with the word Haddock in front * Update Rules.hs * Deal with Haddock failures in getModIfaceRule
…k in front (haskell/ghcide#608) * haskell/ghcide#573, make haddock errors warnings with the word Haddock in front * Update Rules.hs * Deal with Haddock failures in getModIfaceRule
…k in front (haskell/ghcide#608) * haskell/ghcide#573, make haddock errors warnings with the word Haddock in front * Update Rules.hs * Deal with Haddock failures in getModIfaceRule
ghcide
on current master errors out when trying to parse this:with:
But
ghc(i)
does fine:The text was updated successfully, but these errors were encountered: