haskell / haskell/haskell-language-server

Local compiler plugin cannot be loaded in ghcide even with `-fobject-code`

Aperta
#730 1 commento 1 reazione 0 assegnatari Vedi su GitHub
component: ghcide type: bug
Lingua principale
Haskell
Stelle
3k
Fork
455
Merge medio
2g 19h
PR unite (30g)
11

Descrizione

This was originally reported as haskell/haskell-language-server#70, but it turns out that this is a bug in ghcide, so I re-open the issue here.

### Subject of the issue
If one specifies GHC's compiler plugin provided in the *same* package, ghcide fails to find the plugin module.

### Your environment
* ghcide HEAD (10dbde048e8ac028e80f607445776c8375722f75)
* VSCode
* Describe your project: You can use the [same repro repo](/konn/hls-repro) as reported on hls.
* hie.yaml: Provided above.

### Steps to reproduce
1. Set the Languager Server path to the ghcide.
2. Open the src/Lib.hs in the editor.

### Expected behaviour
ghcide should work properly and no bugs must be reported, as `-fobject-code` flag is properly detected by hie-bios.

### Actual behaviour
`Lib` module gets the following error:

```
{
"resource": "/Users/hiromi/Documents/Programming/Haskell/git/hls-repro/src/Lib.hs",
"owner": "Haskell (hls-repro)",
"severity": 8,
"message": "Unexpected usage error\nCould not load module ‘Lib.Plugin’\nIt is a member of the hidden package ‘hls-repro-0.1.0.0’.\nPerhaps you need to add ‘hls-repro’ to the build-depends in your .cabal file.\n",
"source": "pragmas",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 2,
"endColumn": 1
}
```

(Note that the error message has changed since the first report)

### Possible cause
It seems that the cause of this behaviour is the lack of dependency information in `HsEnv` value obtained in `getModSummaryRule`, which is finally passed to `Development.IDE.Core.Preprocessor.preprocess`.
I once tried to expand the definition of `GhcSessionDeps` definition into `getModSummaryRule`, but it won't work since the core logic contains the call for `GetModSummaryWithoutTimestamps`, which eventually calls `GetModSummary`, resulting in cyclic dependency and ghcide stuck in the infinite loop.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.