orphan family instances can leak through the EPS in --make mode
In --make mode there is a single EPS whose eps_fam_inst_env holds all type family instances that have been read from interface files from external packages for any reason. The type checker uses this field pervasively via tcGetFamInstEnvs.
When compiling multiple files it's fairly easy to set up a situation in which
- the first module to be compiled
Aloads an interface fileO.hifrom another package containing an orphan family instance (say, because it imports the module directly); - a later module
Buses this instance to reduce a type, even thoughBhas no dependency at all on the moduleOdefining the instance.
(The only tricky bit in arranging this is that since B cannot depend on A, a little good fortune is needed for GHC to decide to compile B after A.)
Now another module could import B and obtain a function whose definition relies on a type family instance that is not visible from B at all, compromising type safety.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |