Ticket #4233 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

GHC internal error: `w' is not in scope during type checking, but it passed the renamer

Reported by: lilac Owned by:
Priority: normal Milestone:
Component: Template Haskell Version: 6.12.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Compile-time crash Difficulty:
Test Case: Th/T4233 Blocked By:
Blocking: Related Tickets:

Description

{-# LANGUAGE TypeFamilies, TypeOperators, TemplateHaskell #-}
import Language.Haskell.TH
type family a :<=: b
w = varT (mkName "w")
f = [t|Maybe $w :<=: Int|]

fails with

    GHC internal error: `w' is not in scope during type checking, but it passed the renamer
    tcg_type_env of environment: [(rgd, Type constructor `:<=:')]
    In the expression: w
    In the Template Haskell quotation [t| Maybe $w :<=: Int |]
    In the expression: [t| Maybe $w :<=: Int |]

This testcase was produced by attempting to cut down a case which produces:

ghc: panic! (the 'impossible' happened)
  (GHC version 6.12.1 for x86_64-unknown-linux):
        nameModule way{v a37C}

I don't know whether the underlying cause is the same. In both cases the bug can be avoided by a refactoring:

a x = [t|Maybe $x|]
f = conT ''(:<=:) `appT` a x `appT` [t|Int|]

Change History

Changed 3 years ago by lilac

Simpler testcase:

w = varT (mkName "w")
f = [t|$w|]

Changed 3 years ago by igloo

  • status changed from new to closed
  • resolution set to fixed

Thanks for the report. I can reproduce this with 6.12.3, but it works in the HEAD.

Changed 3 years ago by simonpj

  • testcase set to Th/T4233
Note: See TracTickets for help on using tickets.