[GHC] #15523: GHC Panic on malformed newtype and StrictData

#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

#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 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5070 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * differential: => Phab:D5070 Comment: Fortunately, the bug is not present in master. I put a regression test on Phab. {{{ $ ghc -O T15523 [1 of 1] Compiling Main ( T15523.hs, T15523.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 $ head/inplace/bin/ghc-stage2 T15523 [1 of 1] Compiling Main ( T15523.hs, T15523.o ) T15523.hs:5: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’ | 5 | newtype Duration = Foo | ^^^ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15523#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15523: GHC Panic on malformed newtype and StrictData -------------------------------------+------------------------------------- Reporter: rdnetto | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5070 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15523#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15523: GHC Panic on malformed newtype and StrictData -------------------------------------+------------------------------------- Reporter: rdnetto | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5070 Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): For the sake of historical curiosity, commit faec8d358985e5d0bf363bd96f23fe76c9e281f7 (`Track type variable scope more carefully.`) is what fixed this bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15523#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15523: GHC Panic on malformed newtype and StrictData
-------------------------------------+-------------------------------------
Reporter: rdnetto | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5070
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Krzysztof Gogolewski

#15523: GHC Panic on malformed newtype and StrictData -------------------------------------+------------------------------------- Reporter: rdnetto | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5070 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15523#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC