panic: `Prelude.chr: bad argument` in GHC < 8.10 when stale interface is present
Summary
With .hi
and .o
left over from compilation with GHC-9.0.1, older GHC versions panic, e.g.:
$ ghc-8.8.4 AbsTest.hs
ghc: panic! (the 'impossible' happened)
(GHC version 8.8.4 for x86_64-apple-darwin):
Prelude.chr: bad argument: 4043309068
I tested 7.6 - 8.8.
Steps to reproduce
I can reproduce the issue with this script:
# Generate *.o *.hi that trip up older GHCs
ghc-9.0.1 Test.hs
# Produce panics in older GHCs
ghc-7.6.3 Test.hs
ghc-7.8.4 Test.hs
ghc-7.10.3 Test.hs
ghc-8.0.2 Test.hs
ghc-8.2.2 Test.hs
ghc-8.4.4 Test.hs
ghc-8.6.4 Test.hs
ghc-8.8.4 Test.hs
# From 8.10, this seems fixed
ghc-8.10.4 Test.hs
ghc-9.0.1 Test.hs
The source file Test.hs
is an empty module:
module Test where
Expected behavior
What do you expect the reproducer described above to do?
No panic, but ignore stale products and recompile.
Environment
- GHC version used: 7.6 - 8.8
- Operating System: macOS