Home package modules silently override available modules from package database
|Reported by:||ezyang||Owned by:||ezyang|
|Type of failure:||GHC accepts invalid program||Test Case:|
|Related Tickets:||Differential Rev(s):|
Description (last modified by )
To see this, define a module with the same name as some module in base. GHC will compile this:
module Data.List where foo = 2 module A where import Data.List x = print foo
This behavior is intentional; the most compelling reason of behaving this way is that if you are calling
-hide-all-packages, some random package you installed which just happened to provide a module name that conflicted with yours could cause your code to stop compiling if we treated the package database and home packages equally.
However, this behavior seems undesirable when
-hide-all-packages is provided; at the very least, it seems like you might want to provide a warning that you're defining a module which conflicts with a module from a package you have exposed.
This behavior will be further undesirable when signatures come into the picture. Now, I will want to include a package containing a signature for
A, and FURTHERMORE I may want to declare a signature
A.hsig in the local package which augments this signature with some extra declarations I need. Under the current behavior, the externally imported signature is just ignored entirely, even though I wanted them to be merged together. (A counter argument is that this is confusing for users, who will see the use of a declaration, browse to the local hsig file, and not see it defined; thus this mode of use should be disallowed.)
My proposal is to switch the behavior so that we don't prefer home modules if
-hide-all-packages is provided. What's not great about this proposal is that it adds yet another discrepancy between bare GHC use and GHC use with
-hide-all-packages. I'm interested to know what people would like.