GHC uses source files from `.` even when `.` is not passed to `-i` (or is excluded).
Summary
(Relevant cabal bug)
The problem regards -i
. Specifically you cannot exclude .
(pwd) from the search path. Manual section.
Steps to reproduce
f@mkiii:/tmp/ghc-test$ tree .
.
├── Foo.hs
└── src
└── Foo.hs
2 directories, 2 files
f@mkiii:/tmp/ghc-test$ cat Foo.hs
module Foo where
foo :: Int
foo = "bar"
f@mkiii:/tmp/ghc-test$ cat src/Foo.hs
module Foo where
foo :: Int
foo = 23
Notice how ./Foo.hs
has an error in it, but ./src/Foo.hs
is correct.
f@mkiii:/tmp/ghc-test$ ghc -i -isrc Foo
Note we are invoking ghc with an empty -i
, which, according to the manual, “resets the search path back to nothing.”
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )
Foo.hs:4:7: error: [GHC-83865]
• Couldn't match type ‘[Char]’ with ‘Int’
Expected: Int
Actual: String
• In the expression: "bar"
In an equation for ‘foo’: foo = "bar"
|
4 | foo = "bar"
| ^^^^^
but Foo.hs
is not ignored.
Expected behavior
./Foo.hs
is ignored, compilations end without errors.
Environment
- GHC version used: 9.6.2
Optional:
- Operating System: Debian 12.1
- System Architecture: Linux x86_64