[GHC] #15523: GHC Panic on malformed newtype and StrictData
GHC
ghc-devs at haskell.org
Wed Aug 15 08:58:21 UTC 2018
#15523: GHC Panic on malformed newtype and StrictData
-------------------------------------+-------------------------------------
Reporter: rdnetto | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
The following source causes a panic:
{{{#!hs
{-# 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).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15523>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list