Skip to content

Ambiguous interface errors in GHCi, even with -XPackageImports

Originally reported in https://github.com/haskell/cabal/issues/4253, but I moved it here after being reassured that this was a GHCi bug, not a Cabal one.

To reproduce this issue, you'll need to install two libraries that export two constructors with the same name. The original issue uses GLFW and GLFW-b as examples, but for the puposes of test case minimalization, I've prepared a repo here (https://github.com/RyanGlScott/cabal-gh4253) with as small of an example as I can manage. To reproduce the issue, do the following:

$ git clone https://github.com/RyanGlScott/cabal-gh4253
$ cd cabal-gh4253/
$ cabal install package1/ package2/
$ ghci -XPackageImports
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
λ> import "package1" DuplicateModuleName
λ> Window

<interactive>:1:1: error:
    Ambiguous interface for ‘DuplicateModuleName’:
      it was found in multiple packages:
      package1-0.1.0.0 package2-0.1.0.0

This seems to be specific to GHCi, because I cannot find a way to trigger the same issue with ghc --make.

I've reproduced this with GHC 8.0.2 and HEAD.

Trac metadata
Trac field Value
Version 8.0.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHCi
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ezyang
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information