Make it a warning (not error) to hide an import that isn't exported
We often see build failures like
Module `Prelude' does not export `catch'
elicited by an import
statement
import Prelude hiding( catch )
John Lato and others suggest making this a warning, not an error. Simon and I agree and we propose to do this for GHC 7.6, thus:
- Warn, rather than error, when a
hiding
clause mentions something that the module does not export. - Suppress with warning with
-fno-warn-dodgy-imports
, an existing warning-suppression flag. - Document the change, in the
-fwarn-docugy-imports
flag, and the release notes.
We propose to make this change without a language extension. Doing so is technically wrong, since H2010 says it's an error to mention something in hiding
that isn't exported, but it seems too heavyweight to make a language extension just for this; and in any case it would have to be on by default to be any use in practice.
Paolo, can you do all this?
- The relevant function is
RnNames.filterImports
. - I suggest you make
lookup_ie
returnTcRn [(LIE Name,AvailInfo)]
rather than theMaybeErr ...
that it currently returns. - The
want_hiding
flag isTrue
if this is a hiding clause; in that casebad_ie
should warn (unless the warning is suppressed) rather than error.
Trac metadata
Trac field | Value |
---|---|
Version | 7.4.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | highest |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |