-XPackageImports breaks module hiding
Summary
-XPackageImports breaks hiding on each module that it is used.
Steps to reproduce
Sample module:
❯ cat Foo.hs
{-# language PackageImports #-}
module Foo (String) where
import "base" Prelude hiding (String)
data String = String
Attempt to build:
❯ ghc Foo.hs
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )
Foo.hs:3:13: error:
Ambiguous occurrence ‘String’
It could refer to
either ‘Prelude.String’,
imported from ‘Prelude’ at Foo.hs:3:8-10
(and originally defined in ‘GHC.Base’)
or ‘Foo.String’, defined at Foo.hs:7:1
|
3 | module Foo (String) where
|
Even though 'Prelude.String' is hidden.
Removing the use of -XPackageImports
resolves the issue:
❯ cat Foo.hs
{-# language PackageImports #-}
module Foo (String) where
import Prelude hiding (String)
data String = String
Building the version without -XPackageImports
:
❯ ghc Foo.hs
[1 of 1] Compiling Foo ( Foo.hs, Foo.o )
Expected behavior
I would expect that both versions of Foo
would build just fine.
Environment
- GHC version used: 8.10.2
Optional:
- Operating System: NixOS