[GHC] #13215: Panic: push_bang_into_newtype_arg

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash or panic Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Just for fun I tried to compile Agda using `-XStrict`. Result: {{{ [...] [235 of 324] Compiling Agda.Syntax.Translation.InternalToAbstract [...] ghc: panic! (the 'impossible' happened) (GHC version 8.0.2 for i386-unknown-linux): push_bang_into_newtype_arg {} }}} To reproduce (using GHC 8.0.2): {{{ git clone https://github.com/agda/agda.git cd agda git checkout f8a24fe9ed50e4287bc7308e2b3da4615db87aa8 cabal install --ghc-options=-XStrict --constraint=EdisonCore==1.3.1.1 --constraint=EdisonAPI==1.3.1 --constraint=base==4.9.1.0 --constraint=ghc- prim==0.5.0.0 --constraint=rts==1.0 --constraint=integer-gmp==1.0.0.1 --constraint=mtl==2.2.1 --constraint=transformers==0.5.2.0 --constraint=QuickCheck==2.9.2 --constraint=containers==0.5.7.1 --constraint=array==0.5.1.1 --constraint=deepseq==1.4.2.0 --constraint=random==1.1 --constraint=time==1.6.0.1 --constraint=template- haskell==2.11.1.0 --constraint=ghc-boot-th==8.0.2 --constraint=pretty==1.1.3.3 --constraint=tf-random==0.5 --constraint=primitive==0.6.1.0 --constraint=binary==0.8.3.0 --constraint=bytestring==0.10.8.1 --constraint=boxes==0.1.4 --constraint=split==0.2.3.1 --constraint=data-hash==0.2.0.1 --constraint=directory==1.3.0.0 --constraint=filepath==1.4.1.1 --constraint=unix==2.7.2.1 --constraint=edit-distance==0.2.2.1 --constraint=equivalence==0.3.1 --constraint=STMonadTrans==0.3.4 --constraint=transformers-compat==0.5.1.4 --constraint=geniplate- mirror==0.7.4 --constraint=gitrev==1.2.0 --constraint=process==1.4.3.0 --constraint=hashable==1.2.5.0 --constraint=text==1.2.2.1 --constraint=hashtables==1.2.1.0 --constraint=vector==0.11.0.0 --constraint=haskeline==0.7.3.0 --constraint=terminfo==0.4.0.2 --constraint=ieee754==0.7.9 --constraint=monadplus==1.4.2 --constraint =murmur-hash==0.1.0.9 --constraint=parallel==3.2.1.0 --constraint=regex- tdfa==1.2.2 --constraint=parsec==3.1.11 --constraint=regex-base==0.93.2 --constraint=strict==0.3.2 --constraint=unordered-containers==0.2.7.2 --constraint=xhtml==3000.2.1 --constraint=zlib==0.6.1.2 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): Thanks. Here is a small reproduction. {{{ {-# LANGUAGE Strict #-} newtype F = F Int foo (F {}) = () }}} The fix looks to be very easy. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): The problem in the example is in the instance for `Reify MetaId Expr` if this is blocking you. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * owner: => mpickering -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): What is the fix? Generally we are transforming {{{ f !(F n) = ... }}} into {{{ f (F !n) = ... }}} What if it's this? {{{ f !(F {}) = ... }}} We do still need to be strict. So perhaps we transform to {{{ f (F !_) = ... }}} Looks ok to me (with a Note). Could you execute on that? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3057 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * status: new => patch * differential: => Phab:D3057 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3057 Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): Unfortunately, I don't see how to fix this properly like you suggest. In order to construct a `WildPat` we need to know the type the wildcard is meant to be, this information is not maintained anywhere in the `ConPatOut`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3057 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Sure it is! The `ConPatOut` has the type args of data con `pat_arg_tys`. And `dataConInstArgTys` will convert that list to a (singleton in this case) list of arg tys for the newtype constructor. Thanks for working on this -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3057 Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): The `pat_arg_tys` list is empty in this example, that was the first thing I tried. Is that a bug? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3057 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): No, it's not a bug. Consdier {{{ newtype T a b c = MkT (c, Maybe (a,b)) f :: T Int [x] y -> Bool f (MkT v) = ... }}} In the `ConPatOut` for `MkT` the `pat_arg_tys` will be a 3-element list, of `Int`, `[x]`, and `y`. When you call `dataConInstArgTys MkT <that list>` you'll get the singleton list back containing the type of `MkT`'s value arg: `(y, Maybe (Int,[x]))`. Now if `T` had no arguments thut {{{ newtype T = MkT (Int -> Int) }}} then of course `pat_arg_tys` will be empty, but `dataConInstArgTys` will return the singleton contianing `Int -> Int`. Does that help? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3057 Wiki Page: | -------------------------------------+------------------------------------- Comment (by mpickering): Thanks Simon. That makes sense, I updated the diff now and also the old test for #9844 to test the strictness properties. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13215: Panic: push_bang_into_newtype_arg -------------------------------------+------------------------------------- Reporter: nad | Owner: mpickering Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.0.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3057 Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * status: patch => closed * resolution: => fixed Comment: Merged as 062f112388ac879dc78a9a0c5a947894d20cd899 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13215#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC