haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.72k stars 367 forks source link

`if impl(ghcjs) XXX else YYY` should process both XXX and YYY (like it does for flags), but instead chooses none #2120

Closed srghma closed 10 months ago

srghma commented 3 years ago

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 1.3.0.0 (GHC: 8.10.4) (PATH: /nix/store/4wkv3mi2hidvbgvmibvjgyzp5nbnqzw6-haskell-language-server-1.3.0-installer/bin/haskell-language-server-wrapper) (GIT hash: e7c5e90b6df5dff2760d76169eddaea3bdd6a831)
Tool versions found on the $PATH
cabal:          3.0.0.0
stack:          Not found
ghc:            8.6.5

Which OS do you use: NixOs

Which lsp-client do you use: Vs Code

Describe your project (alternative: link to the project): it's a develop branch https://github.com/reflex-frp/reflex-platform/commit/55da77c8654c2f9a78c446ee730688bf94a7bde4 , but I have added

  tryReflexShell = pinBuildInputs ("shell-" + system) (tryReflexPackages ++
    (
      let
        inherit (nixpkgs) callPackage fetchFromGitHub mkShell;
        easy-hls-src = fetchFromGitHub {
          owner  = "jkachmar";
          repo   = "easy-hls-nix";
          rev    = "6cb50f04e3a61b1ec258c6849df84dae9dfd763f";
          sha256 = "1rvi6067nw64dka8kksl7f34pwkq7wx7pnhnz3y261fw9z5j4ndp";
        };
        easy-hls = callPackage easy-hls-src {
          ghcVersions = [ "8.6.5" ];
        };
      in
        [easy-hls]
    )
  );

and run ./try-reflex

check this comment

Contents of hie.yaml: without hie.yaml file

Steps to reproduce

I clone this repo and execute

./scripts/hack-on haskell-overlays/reflex-packages/dep/universe
./scripts/hack-on haskell-overlays/reflex-packages/dep/dependent-sum-universe-orphans
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex
./scripts/hack-on haskell-overlays/reflex-packages/dep/cabal-macosx
./scripts/hack-on haskell-overlays/reflex-packages/dep/jsaddle-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/ghcjs-dom
./scripts/hack-on haskell-overlays/reflex-packages/dep/dependent-monoidal-map
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-todomvc
./scripts/hack-on haskell-overlays/reflex-packages/dep/gargoyle
./scripts/hack-on haskell-overlays/reflex-packages/dep/reflex-aeson-orphans
./scripts/hack-on haskell-overlays/reflex-packages/dep/jsaddle
./scripts/hack-on haskell-overlays/reflex-packages/dep/patch
./try-reflex
code .

hack-on is using https://github.com/obsidiansystems/nix-thunk to replace the contents of dir (e.g. https://github.com/reflex-frp/reflex-platform/blob/develop/haskell-overlays/reflex-packages/dep/reflex/) with the actual repo

so, I see that reflex compiles, but this module https://github.com/reflex-frp/reflex-dom/blob/6a7782a61e90e7369a8278441eb47f702bb7c63b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs#L148 throws error

Could not load module ‘Foreign.JavaScript.Internal.Utils’
it is a hidden module in the package ‘reflex-dom-core-0.6.2.0’not found

this is because of (I think)

  if impl(ghcjs)
    hs-source-dirs: src-ghcjs
    build-depends:
      ghcjs-base,
      hashable >= 1.2 && < 1.4
  else
    hs-source-dirs: src-ghc
    if !os(windows)
      build-depends: unix == 2.7.*

I THINK it doesn't choose any of this cases, but should EITHER:

I don't really know how it SHOULD work

Include debug information

  1. in the bottom of this comment you can find a logs of vscode when it loads Immediate.hs
  2. haskell-language-server-wrapper --debug . 2>&1 | tee haskell-language-server-wrapper.log (here you can find only part of log -- if program is started outside vscode, the log is neverending and all 36gb of memory of my computer gets consumed, I have to kill program even after CTRL-C, probably there is a memory leak)
michaelpj commented 10 months ago

We just ask cabal what to do, it's cabal that makes decisions here. I think there is certainly some confusion about what to do fro cross usecases but I'm not sure what to do about it.