Out-of-scope suggestion given for an out-of-scope variable when using TH
With GHC 8.x, compiling
{-# LANGUAGE TemplateHaskell #-}
module A where
import Language.Haskell.TH
sep :: Q [Dec]
sep = [d| x = () |]
and
{-# LANGUAGE TemplateHaskell #-}
module B where
import A
f :: Int
f = foo
$(sep)
foo :: Int
foo = 3
produces
$ ghc-HEAD/inplace/bin/ghc-stage2 --version
The Glorious Glasgow Haskell Compilation System, version 8.1.20160303
$ ghc-HEAD/inplace/bin/ghc-stage2 B.hs
[1 of 2] Compiling A ( A.hs, A.o )
[2 of 2] Compiling B ( B.hs, B.o )
B.hs:8:5: error:
• Variable not in scope: foo :: Int
• Perhaps you meant ‘foo’ (line 13)
The problem is that when the typechecker constructs the suggestion, it uses the
currently available GlobalRdrEnv
rather than the one in existence when
the renamer determined that foo
is unbound.
Trac metadata
Trac field | Value |
---|---|
Version | 8.0.1-rc2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |