[GHC] #12034: Template Haskell + hs-boot = Not in scope during type checking, but it passed the renamer

GHC ghc-devs at haskell.org
Tue May 10 03:54:30 UTC 2016


#12034: Template Haskell + hs-boot = Not in scope during type checking, but it
passed the renamer
-------------------------------------+-------------------------------------
           Reporter:  ezyang         |             Owner:
               Type:  bug            |            Status:  new
           Priority:  low            |         Milestone:
          Component:  Compiler       |           Version:  8.0.1-rc2
  (Type checker)                     |
           Keywords:  backpack       |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 I don't think this is a very harmful bug but it definitely is a bug.
 Consider:

 {{{
 -- A.hs-boot
 module A where
 data T

 -- B.hs
 module B (module A) where
 import {-# SOURCE #-} A

 -- A.hs
 {-# LANGUAGE TemplateHaskell #-}
 module A where
 import qualified B
 import Language.Haskell.TH
 f :: B.T -> B.T
 f x = x
 $( return [] )
 data T = T B.T
 }}}

 The point of the splice is to convince GHC to typecheck `f :: B.T -> B.T`
 before it typechecks the type declaration. But this is not going to work,
 because `tcLookupGlobal` is going to bail if (1) T is not in the
 `tcg_type_env` and (2) T comes from this module.

 It would be a simple matter to improve the error message but from a user's
 perspective, there is no good reason for this to not typecheck.  On the
 implementation side, I am sympathetic to not letting this typecheck: if it
 does typecheck, then some `TyCon`s will incorrectly refer to the
 definition from the hs-boot file, rather than our local definition.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12034>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list