Skip to content

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

@konn

Description

@konn

This was originally reported as #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 (10dbde0)
  • VSCode
  • Describe your project: You can use the same repro repo 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: ghcidetype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions