Ticket #5777 (new bug)

Opened 16 months ago

Last modified 3 months ago

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

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

Change History

Changed 16 months ago by benmos

Core Lint output

Changed 16 months ago by benmos

Source file

  Changed 16 months 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 -< ()

follow-up: ↓ 7   Changed 16 months 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

  Changed 16 months ago by igloo

  • difficulty set to Unknown
  • milestone set to 7.4.2

  Changed 13 months ago by danbst

  • cc abcz2.uprola@… added

  Changed 12 months ago by igloo

  • milestone changed from 7.4.2 to 7.4.3

  Changed 8 months ago by igloo

  • milestone changed from 7.4.3 to 7.6.2

in reply to: ↑ 2   Changed 4 months ago by altaic

  • version changed from 7.4.1-rc1 to 7.4.2
  • architecture changed from x86 to Unknown/Multiple

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

  Changed 4 months ago by simonpj

  • cc ross added

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

  Changed 4 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.

  Changed 3 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.