tfausak / purple-yolk

:hatching_chick: A Haskell IDE for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=taylorfausak.purple-yolk
MIT License
26 stars 2 forks source link

Wrong path is used to open diagnostics' file #43

Closed EduardSergeev closed 10 months ago

EduardSergeev commented 10 months ago

When a default "Stack + Cabal" project (i.e. created via stack new --bare kurt command) is opened using the following purple-yolk.haskell.interpreter.command command:

stack ghci --ghci-options -ddump-json

the errors do get correctly reported in VSCode Problems tab however if you click on the actual error in VSCode Problems tab it then tries to open corresponding file using invalid path which results in the following error message in VSCode:

image

Logs show that GHCi does report a correct path for the file with error, e.g.:

2023-08-26T01:17:23.794Z [7d4c] [stderr]     /home/edka/work/haskell/cabal/app/Main.hs.

but this extension tried to open this file using the following invalid path instead:

/home/edka/work/haskell/cabal/home/edka/work/haskell/cabal/app/Main.hs 
tfausak commented 10 months ago

Huh, weird. Stack and Cabal must call GHC with different paths. Here's what I see from stack ghci --ghci-options -ddump-json:

{
  "doc": "• Couldn't match expected type ‘a’ with actual type ‘()’\n  ‘a’ is a rigid type variable bound by\n    the type signature for:\n      oh_no :: forall a. a\n    at /workspaces/scratch/library/Scratch.hs:3:1-10\n• In the expression: ()\n  In an equation for ‘oh_no’: oh_no = ()\n• Relevant bindings include\n    oh_no :: a (bound at /workspaces/scratch/library/Scratch.hs:4:1)",
  "messageClass": "MCDiagnostic SevError ErrorWithoutFlag Just GHC-25897",
  "span": {
    "endCol": 11,
    "endLine": 4,
    "file": "/workspaces/scratch/library/Scratch.hs",
    "startCol": 9,
    "startLine": 4
  }
}

Note that the file path is absolute.

And here's what I see from cabal repl --repl-options -ddump-json:

{
  "doc": "• Couldn't match expected type ‘a’ with actual type ‘()’\n  ‘a’ is a rigid type variable bound by\n    the type signature for:\n      oh_no :: forall a. a\n    at library/Scratch.hs:3:1-10\n• In the expression: ()\n  In an equation for ‘oh_no’: oh_no = ()\n• Relevant bindings include\n    oh_no :: a (bound at library/Scratch.hs:4:1)",
  "messageClass": "MCDiagnostic SevError ErrorWithoutFlag Just GHC-25897",
  "span": {
    "endCol": 11,
    "endLine": 4,
    "file": "library/Scratch.hs",
    "startCol": 9,
    "startLine": 4
  }
}

Note that the file path is relative.