Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,332
    • Issues 4,332
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 363
    • Merge Requests 363
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #1651

Closed
Open
Opened Aug 30, 2007 by Manuel M T Chakravarty@mchakravartyReporter

panic when interactively evaluating expression with a family type

{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE EmptyDataDecls #-}

newtype Succ a = Succ a deriving Show
data    Zero   = Zero
instance Show Zero where show _ = "Zero"

type family Add a b
type instance Add Zero a     = a
type instance Add (Succ n) m = Succ (Add n m)

add :: a -> b -> Add a b
add = undefined

okay = show $ add Zero Zero
bad  = add Zero Zero

{- ghci transcript:

*Main> okay
"Zero"
*Main> bad
ghc-6.7.20070828: panic! (the 'impossible' happened)
  (GHC version 6.7.20070828 for i386-unknown-linux):
    readFilledBox t_a1D9{tv} [box]

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

*Main> show bad

<interactive>:1:0:
    No instance for (Show (Add Zero Zero))
      arising from a use of `show' at <interactive>:1:0-7
    Possible fix:
      add an instance declaration for (Show (Add Zero Zero))
    In the expression: show bad
    In the definition of `it': it = show bad
-}

The panic arises as follows: tcGhciStmts calls TcMatches.tcDoStmt to type check it <- bad, which in turn evaluates

 withBox liftedTypeKind $ \ pat_ty -> 
   tcMonoExpr rhs (mkAppTy m_ty pat_ty)

The withBox executes the readfilledBox that causes the panic, as tcMonoExpr promises to fill the boxes in its second argument. This promise is not fulfilled, as tcMonoBox defers the match Add Zero Zero ~ IO t_ayP.

Further up the call chain tcGhciStmts will eventually simplify the LIE and would discover the type mismatch (and hence abandon "Plan A", of which all this is part). Unfortunately, we never get there due to withBoxs attempt to read t_avP.

Trac metadata
Trac field Value
Version 6.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC chak@cse.unsw.edu.au
Operating system Unknown
Architecture Unknown
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#1651