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,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 404
    • Merge Requests 404
  • 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
  • #6114

Closed
Open
Opened May 19, 2012 by davidmiani@trac-davidmiani

ghc: panic! occurred with use of isInstance, newName and a type splice

Compiling the below code:

{-# LANGUAGE TemplateHaskell #-}
module Test where
import Language.Haskell.TH
import Control.Monad.Instances ()    

instanceVar = $(do
                 xName <- newName "x"
                 instanceType <- [t| (Int -> $(varT xName)) |]
                 instanceOfFunctor <- isInstance ''Functor [instanceType]
                 stringE $ show instanceOfFunctor
               )

Results in the following error:

[1 of 1] Compiling Test             ( test.hs, interpreted )

test.hs:6:17:
    Exception when trying to run compile-time code:
      ghc: panic! (the 'impossible' happened)
  (GHC version 7.4.1 for x86_64-apple-darwin):
	nameModule x_a1ws{tv}

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

      Code: do { xName <- newName "x";
                 instanceType <- [t| Int -> $(varT xName) |]
                                 pending [(splice, varT xName)];
                 instanceOfFunctor <- isInstance ''Functor [instanceType];
                 .... }
    In the expression:
      $(do { xName <- newName "x";
             instanceType <- [t| Int -> $(varT xName) |];
             instanceOfFunctor <- isInstance ''Functor [instanceType];
             .... })
    In an equation for `instanceVar':
        instanceVar
          = $(do { xName <- newName "x";
                   instanceType <- [t| Int -> $(varT xName) |];
                   .... })
Failed, modules loaded: none.

While the code is not correct (replacing the instanceType line with

instanceType <- [t| (->) Int |]

fixes the problem), a better error message would be desirable.

Trac metadata
Trac field Value
Version 7.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#6114