Duplicate signatures clobbered in .bkp files
Summary
In .bkp files, it is possible to declare a signature multiple times within a unit, and it appears that only the last signature of a given name is considered; all others are ignored. I'm not certain if this is actually a bug, or how this is supposed to behave. cc @ezyang
Steps to reproduce
Write the following into a file test.bkp:
unit test where
-- These two declarations of @signature A@ should be mergeable
signature A where
f :: Int
signature A where
g :: String
-- These two declarations of @signature B@ are certainly not mergeable
signature B where
f :: Int
signature B where
f :: String
Then run ghc --backpack test.bkp, and inspect the generated .hi files with ghc --show-iface test/A.hi and ghc --show-iface test/B.hi.
Observed behaviour: GHC succeeds and writes out hi files for both A and B. A.hi lists only g :: String among its exports, and B.hi lists only f :: String among its exports.
Expected behavior
I am not entirely sure how signature merging is supposed to work in this scenario, but I expected one of two things to happen here:
- GHC would point out that
AandBhave both been declared multiple times, and no.hifiles would be produced at all - GHC would produce an
A.hifile which listed bothf :: Intandg :: Stringas exports, but would fail with an error at B, saying that the signatures were not mergeable
Environment
- GHC version used: reproduced on both 8.10.4 and 9.0.1
Optional:
- Operating System: Ubuntu linux
- System Architecture: x86_64