GHC Panic on malformed newtype and StrictData
The following source causes a panic:
{-# LANGUAGE StrictData #-}
module Main where
newtype Duration = Foo
data Literal = LitDuration Duration
Result:
[1 of 1] Compiling Main ( src/Main.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/build/tcalc/tcalc-tmp/Main.o )
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.3 for x86_64-unknown-linux):
mkNewTyConRhs
Foo []
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/iface/BuildTyCl.hs:77:27 in ghc:BuildTyCl
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
If we remove the StrictData pragma, then we get a syntax error as expected:
/home/reuben/tcalc/src/Main.hs:3:20: error:
• The constructor of a newtype must have exactly one field
but ‘Foo’ has none
• In the definition of data constructor ‘Foo’
In the newtype declaration for ‘Duration’
|
3 | newtype Duration = Foo
| ^^^
I was able to reproduce this with GHC 8.4.3 and 8.2.2 (using Stack LTS snapshots). GHC 8.0.2 is not affected.
A test case buildable with Stack can be found at https://github.com/rdnetto/tcalc/tree/ghc-bug (i.e. on the ghc-bug branch).
Trac metadata
Trac field | Value |
---|---|
Version | 8.4.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |