haskell / haskell/haskell-language-server
Eval plugin uses language extensions of the caller in imported modules
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 12
Description
### Your environment
Which OS do you use:
Ubuntu 20.04 LTS inside WSL 2 (Windows 10 21H2)
Which LSP client (editor/plugin) do you use:
VS Code + haskell extension, HLS 1.4 from Nixpkgs 21.11 running in nix-shell
Compiler:
GHC 8.10.7
Describe your project (alternative: link to the project):
Library-only cabal project with two files: lib/A.hs, lib/B.hs
### Steps to reproduce
lib/A.hs:
```haskell
module A where
foo :: Char -> Bool
foo c = c `elem` ['\\']
```
lib/B.hs:
```haskell
{-# LANGUAGE OverloadedLists #-}
module B where
import A
import Data.Sequence
-- >>> foo <$> ['\\'] :: Seq Bool
```
### Expected behaviour
Eval plugin should print:
-- fromList [True]
### Actual behaviour
Pop-up window shows with the following message:
```
These modules are needed for compilation but not listed in your .cabal file's other-modules:
A B • Couldn't match expected type ‘GHC.Exts.Item (t0 Char)’
with actual type ‘Char’
The type variable ‘t0’ is ambiguous
• In the expression: '\\'
In the second argument of ‘elem’, namely ‘['\\']’
In the expression: c `elem` ['\\']
```
It appears to me that eval plugin tries to interpret modules with language pragmas inherited from the caller (B.hs) while it should respect pragmas of the callee (A.hs).
Workaround: type annotations in the callee to resolve ambiguity.
This is however very annoying for my real-world scenario, where callee module is generated by `alex`. This requires to manually patch auto-generated files in two places after each change in the lexer specification.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.