Opened 5 years ago

Closed 5 years ago

#7312 closed bug (fixed)

panic! applytTypeToArgs with non-infix function type constructor

Reported by: jwlato Owned by: simonpj
Priority: normal Milestone: 7.6.2
Component: Compiler (Type checker) Version: 7.6.1
Keywords: Cc: jwlato@…,…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Test Case: typecheck/should_compile/T7312
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


module Foo where

-- this works
--mac :: Double -> (Double->Double) -> (Double-> Double)
--mac ac m = \ x -> ac + x * m x

-- this doesn't
mac2 :: Double -> (->) Double Double -> (->) Double Double
mac2 ac m = \ x -> ac + x * m x

Compiling this with ghc-7.6.1 results in

ghc: panic! (the 'impossible' happened)
  (GHC version 7.6.1 for x86_64-unknown-linux):
    m{v af4} [lid] x{v af5} [lid]
    ghc-prim:GHC.Prim.(->){(w) tc 3D}
      ghc-prim:GHC.Types.Double{(w) tc 3u}
      ghc-prim:GHC.Types.Double{(w) tc 3u}

Attachments (1)

foo.hs (227 bytes) - added by jwlato 5 years ago.

Download all attachments as: .zip

Change History (9)

Changed 5 years ago by jwlato

Attachment: foo.hs added

comment:1 Changed 5 years ago by liyang

Cc:… added

comment:2 Changed 5 years ago by liyang

Type of failure: None/UnknownCompile-time crash

comment:3 Changed 5 years ago by simonpj

difficulty: Unknown
Owner: set to simonpj

Embarrassing but happily easy to fix. I need to validate first though.


comment:4 Changed 5 years ago by simonpj@…

commit 9991890d284272e03f95ad9995bf21ec56ec7524

Author: Simon Peyton Jones <>
Date:   Wed Oct 10 19:10:18 2012 +0100

    Ensure we produce a FunTy for functions (Trac #7312)
    The issue here was with a function type written prefix
      (->) a b
    where we were not generating a FunTy, which blew the
    invariant that function types are always FunTys.  We
    can't look at the TyCon directly because it may be
    knot-tied, so we look at the name instead.

 compiler/typecheck/TcHsType.lhs |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

comment:5 Changed 5 years ago by simonpj

Status: newmerge
Test Case: typecheck/should_compile/T7312

Fixed. Merge to stable please.

comment:6 Changed 5 years ago by igloo

Milestone: 7.6.2

comment:7 Changed 5 years ago by simonpj

When merging, please check whether the change fixes #7372 in the 7.6 branch

comment:8 Changed 5 years ago by igloo

Resolution: fixed
Status: mergeclosed

Merged as 4b295b6ca35e780ba758fc0d02bc789579aeb0fb. Seems to work fine.

Note: See TracTickets for help on using tickets.