Opened 2 years ago

Last modified 14 months ago

#5777 new bug

core lint error with arrow notation and GADTs

Reported by: benmos Owned by: ross
Priority: normal Milestone: 7.6.2
Component: Compiler Version: 7.4.2
Keywords: arrows, GADTs Cc: ross, ben@…, benjamin.moseley@…, abcz2.uprola@…
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: Compile-time crash Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The following code panics GHC (with 7.0.3, 7.2 and 7.4.0.20111219):

{-# LANGUAGE Arrows, GADTs #-}
import Control.Arrow

data Value a where BoolVal :: Value Bool

class ArrowInit f where
    arrif :: f b -> ()

instance ArrowInit Value where
    arrif = proc BoolVal -> returnA -< ()
    -- arrif = arr (\BoolVal -> ())

I am attaching the -dcore-lint from 7.4.

Attachments (2)

arrow-gadt-panic.txt (4.7 KB) - added by benmos 2 years ago.
Core Lint output
Test3.hs (284 bytes) - added by benmos 2 years ago.
Source file

Download all attachments as: .zip

Change History (12)

Changed 2 years ago by benmos

Core Lint output

Changed 2 years ago by benmos

Source file

comment:1 Changed 2 years ago by ross

  • Summary changed from Panic with Arrow Notation and GADTs to core lint error with arrow notation and GADTs

Simplified version, avoiding classes:

{-# LANGUAGE Arrows, GADTs #-}
module ArrowBug5777 where

import Control.Arrow

data Value a where BoolVal :: Value Bool

arrif :: Value Bool -> ()
arrif = proc BoolVal -> returnA -< ()

comment:2 follow-up: Changed 2 years ago by benmos

The workaround is to move the GADT data constructor out of the 'proc' pattern and into a 'let':

data Value a where BoolVal :: Int -> Value Bool

arrif :: Value Bool -> Int
arrif = proc x -> do
          let BoolVal i = x
          returnA -< i

comment:3 Changed 2 years ago by igloo

  • Difficulty set to Unknown
  • Milestone set to 7.4.2

comment:4 Changed 2 years ago by danbst

  • Cc abcz2.uprola@… added

comment:5 Changed 22 months ago by igloo

  • Milestone changed from 7.4.2 to 7.4.3

comment:6 Changed 19 months ago by igloo

  • Milestone changed from 7.4.3 to 7.6.2

comment:7 in reply to: ↑ 2 Changed 15 months ago by altaic

  • Architecture changed from x86 to Unknown/Multiple
  • Version changed from 7.4.1-rc1 to 7.4.2

This also happens on GHC 7.4.2 x86_64.

$ ghc --make Test3.hs 
[1 of 1] Compiling Main             ( Test3.hs, Test3.o )
ghc: panic! (the 'impossible' happened)
  (GHC version 7.4.2 for x86_64-apple-darwin):
	cgLookupPanic (probably invalid Core; try -dcore-lint)
    ( $dArrow{v amL} [lid] :: base:Control.Arrow.Arrow{tc r4n}
                                ghc-prim:GHC.Prim.(->){(w) tc 3D} )
    static binds for:
    local binds for:
    ( main:Main.arrif{v rci} [gid[ClassOp]] :: forall (( f{tv acm} [tv] :: ghc-prim:GHC.Prim.*{(w) tc 34d}
                                                                           -> ghc-prim:GHC.Prim.*{(w) tc 34d} ) :: ghc-prim:GHC.Prim.*{(w) tc 34d}
                                                                                                                   -> ghc-prim:GHC.Prim.*{(w) tc 34d}).
                                               main:Main.ArrowInit{tc rch}
                                                 ( f{tv acm} [tv] :: ghc-prim:GHC.Prim.*{(w) tc 34d}
                                                                     -> ghc-prim:GHC.Prim.*{(w) tc 34d} ) =>
                                               forall ( b{tv acn} [tv] :: ghc-prim:GHC.Prim.*{(w) tc 34d} ).
                                               ( f{tv acm} [tv] :: ghc-prim:GHC.Prim.*{(w) tc 34d}
                                                                   -> ghc-prim:GHC.Prim.*{(w) tc 34d} ) ( b{tv acn} [tv] :: ghc-prim:GHC.Prim.*{(w) tc 34d} )
                                               -> ghc-prim:GHC.Tuple.(){(w) tc 40} )
    ( main:Main.$WBoolVal{v rcH} [gid[DataConWrapper]] :: main:Main.Value{tc rcj}
                                                            ghc-prim:GHC.Types.Bool{(w) tc 3c} )

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

comment:8 Changed 15 months ago by simonpj

  • Cc ross added

Ross, do you feel able to help with this. I have no clue.

comment:9 Changed 15 months ago by ross

  • Owner set to ross

I'll put it on my list, but first priority is ArrForm? (#5267/#5609), followed by infixr (#5333), with this and #344 as the lowest.

comment:10 Changed 14 months ago by simonpj@…

commit c3ad38d7dc39ef583ddfb586413baa2e57ca3ee8

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Mon Mar 4 09:40:56 2013 +0000

    Rearrange the typechecking of arrows, especially arrow "forms"
    
    The typechecking of arrow forms (in GHC 7.6) is known to be bogus, as
    described in Trac #5609, because it marches down tuple types that may
    not yet be fully worked out, depending on when constraint solving
    happens.  Moreover, coercions are generated and simply discarded.  The
    fact that it works at all is a miracle.
    
    This refactoring is based on a conversation with Ross, where we
    rearranged the typing of the argument stack, so that the arrows
    have the form
       a (env, (arg1, (arg2, ...(argn, ())))) res
    rather than
       a (arg1, (arg2, ...(argn, env))) res
    as it was before.
    
    This is vastly simpler to typecheck; just look at the beautiful,
    simple type checking of arrow forms now!
    
    We need a new HsCmdCast to capture the coercions generated from
    the argument stack.
    
    This leaves us in a better position to tackle the open arrow tickets
     * Trac #5777 still fails.  (I was hoping this patch would cure it.)
     * Trac #5609 is too complicated for me to grok.  Ross?
     * Trac #344
     * Trac #5333

 compiler/deSugar/Coverage.lhs     |    3 +
 compiler/deSugar/DsArrows.lhs     |  486 +++++++++++++++++++++----------------
 compiler/hsSyn/HsExpr.lhs         |   13 +-
 compiler/hsSyn/HsUtils.lhs        |    7 +-
 compiler/parser/Parser.y.pp       |    4 +-
 compiler/parser/RdrHsSyn.lhs      |    4 +-
 compiler/rename/RnExpr.lhs        |    4 +-
 compiler/rename/RnTypes.lhs       |    2 +-
 compiler/typecheck/TcArrows.lhs   |  272 ++++++++++-----------
 compiler/typecheck/TcHsSyn.lhs    |    6 +-
 docs/users_guide/glasgow_exts.xml |   48 +++--
 11 files changed, 461 insertions(+), 388 deletions(-)
Note: See TracTickets for help on using tickets.