Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,399
    • Issues 5,399
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 592
    • Merge requests 592
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14933
Closed
Open
Issue created Mar 17, 2018 by Ryan Scott@RyanGlScottMaintainer

DeriveAnyClass can cause "No skolem info" GHC panic

This program panics:

{-# LANGUAGE DefaultSignatures          #-}
{-# LANGUAGE DeriveAnyClass             #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RankNTypes                 #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TypeFamilies               #-}
module Bug where

import Control.Concurrent (ThreadId)
import Control.Monad.Reader

class Wrapped s where
  type Unwrapped s :: *
  _Wrapped' :: Iso' s (Unwrapped s)

type Iso' s a = forall f. Functor f => (a -> f a) -> s -> f s

class Fork m where
    fork :: x -> m () -> m ThreadId

    default fork :: ( Wrapped (m ())
                    , Unwrapped (m ()) ~ t ()
                    , Fork t
                    , Wrapped (m ThreadId)
                    , Unwrapped (m ThreadId) ~ t ThreadId
                    ) => x -> m () -> m ThreadId
    fork = undefined -- view _Unwrapped' . fork . view _Wrapped'

instance Fork m => Fork (ReaderT e m) where
    fork x action = ReaderT $ \env -> fork x (runReaderT action env)

data Env

newtype MyThing m a = MyThing { unMyThing :: ReaderT Env m a }
    deriving newtype  (Functor, Applicative, Monad)
    deriving anyclass (Fork)

instance Wrapped (MyThing m a) where
    type Unwrapped (MyThing m a) = ReaderT Env m a
    _Wrapped' = undefined -- iso unMyThing MyThing
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:39:24: error:ghc: panic! (the 'impossible' happened)
  (GHC version 8.2.2 for x86_64-unknown-linux):
        No skolem info:
  m_a1Hs[sk:2]
  Call stack:
      CallStack (from HasCallStack):
        prettyCurrentCallStack, called at compiler/utils/Outputable.hs:1133:58 in ghc:Outputable
        callStackDoc, called at compiler/utils/Outputable.hs:1137:37 in ghc:Outputable
        pprPanic, called at compiler/typecheck/TcErrors.hs:2653:5 in ghc:TcErrors

(Program adapted from here.)

Trac metadata
Trac field Value
Version 8.2.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking