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

Unknown Language Extension causes crash on startup #34

Closed
fendor opened this issue Oct 14, 2019 · 5 comments · Fixed by #65
Closed

Unknown Language Extension causes crash on startup #34

fendor opened this issue Oct 14, 2019 · 5 comments · Fixed by #65

Comments

@fendor
Copy link
Collaborator

fendor commented Oct 14, 2019

Just need to catch another exception.

Logs
2019-10-14 18:08:11.464696271 [ThreadId 4] - Using plain GHC version
2019-10-14 18:08:11.511825829 [ThreadId 4] - Run entered for HIE(hie-8.6.4) Version 1.0.0.0 x86_64 ghc-8.6.4
2019-10-14 18:08:11.511958694 [ThreadId 4] - Current directory:/home/baldr/Documents/haskell/lambdabot-server
2019-10-14 18:08:11.578019101 [ThreadId 10] - Using plain GHC version
Using hie version: Version 1.0.0.0 x86_64 ghc-8.6.4
2019-10-14 18:08:11.652328132 [ThreadId 12] - New cradle: /home/baldr/Documents/haskell/lambdabot-server/src/Server/Utils.hs
2019-10-14 18:08:11.652740923 [ThreadId 12] - Found cradle: Cradle {cradleRootDir = "/home/baldr/Documents/haskell/lambdabot-server", cradleOptsProg = CradleAction: cabal}
Using hoogle db at: /home/baldr/.hoogle/default-haskell-5.0.17.hoo
hie-8.6.4: Unsupported extension: RecordWildcards
Perhaps you meant ‘RecordWildCards’ or ‘NoRecordWildCards’
@fendor fendor changed the title Unknown Language Extensions causes crash on startup Unknown Language Extension causes crash on startup Oct 14, 2019
@fendor fendor mentioned this issue Nov 19, 2019
26 tasks
@jneira
Copy link

jneira commented Nov 22, 2019

Hi! i am investigating on this and i found that ghc couls throw several Exception's defined inside compiler that are not GhcException:

  • The one that would catch the error about uknown Language Extension is SourceError
  • But there are: GhcApiError, IOEnvFailure, PlainGhcException
  • And it can throw IOException's as well (and maybe other Exceptions defined outside compiler)
    • Maybe it wraps them in one of the previous ones but it is hard to trace all possible code locations where it could be done

Maybe it is not probable but ghc dev could add more Exception's so maybe we could catch AsyncException and SomeException in that order, rethrowing the async ones and wrapping all other ones in Left. What do you think @fendor?

@jneira
Copy link

jneira commented Nov 22, 2019

  • In my case (testing 924de7) using the default cradle (Cabal-Helper-Cabal-v2) with a unknown language extension i don get the log with the error pasted above but Initializating cradle doesnt finish and hover doesnt respond (hangs on Loading)
  • With Handle ghc exceptions #65 i've got an error alert in vscode with "Cannot parse LANGUAGE pragma\nExpecting comma-separated list of language options,\neach starting with a capital letter\n E.g. {-# LANGUAGE TemplateHaskell, GADTs #-}\n"
    • And hover doenst work (but doesnt popup Loading) as expected

@jneira
Copy link

jneira commented Nov 22, 2019

But the behavior catching the exception is not optimal, i.e. the actual of hie master (from ghc-mod): it shows a code error with a quick fix to replace the bad extension name with the more similar good one in any case (editing or just opening the bad file) 😟

Moreover the error alert is shown repeteadly (up to 5 times).

EDIT: If i edit the file and write an incorrect extension the editor shows it correctly as a code error with quick fix but no if i open the file containing already the incorrect extension

@mpickering
Copy link
Owner

@jneira The error comes from depanal, if it can't parse the module header then it throws an exception rather than communicating the error in a nice way like the "save" code path.

@jneira
Copy link

jneira commented Nov 22, 2019

It turns out that SourceError has enough info to create a code error with a quick fix so maybe we have to handle it specifically.

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

Successfully merging a pull request may close this issue.

3 participants