Commit d6186496 authored by Ryan Scott's avatar Ryan Scott

Error eagerly after renaming failures in reifyInstances

Previously, if `reifyInstances` failed to discover a `Name` during
renaming, it would blindy charge into typechecking, at which point GHC would
become very confused at the absence of that `Name` and throw an internal error.
A simple workaround is to fail eagerly after renaming errors.

Test Plan: make test TEST=T13837

Reviewers: goldfire, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13837

Differential Revision:
parent ad0037ea
......@@ -1138,7 +1138,11 @@ reifyInstances th_nm th_tys
; let tv_rdrs = freeKiTyVarsAllVars free_vars
-- Rename to HsType Name
; ((tv_names, rn_ty), _fvs)
<- bindLRdrNames tv_rdrs $ \ tv_names ->
<- checkNoErrs $ -- If there are out-of-scope Names here, then we
-- must error before proceeding to typecheck the
-- renamed type, as that will result in GHC
-- internal errors (#13837).
bindLRdrNames tv_rdrs $ \ tv_names ->
do { (rn_ty, fvs) <- rnLHsType doc rdr_ty
; return ((tv_names, rn_ty), fvs) }
; (_tvs, ty)
{-# LANGUAGE TemplateHaskell #-}
module T13837 where
import Language.Haskell.TH.Lib
import Language.Haskell.TH.Syntax
test_local_tyfam_expansion :: String
test_local_tyfam_expansion =
$(do fam_name <- newName "Fam"
stringE . show =<< qReifyInstances fam_name [])
T13837.hs:9:5: error:
• The exact Name ‘Fam’ is not in scope
Probable cause: you used a unique Template Haskell name (NameU),
perhaps via newName, but did not bind it
If that's it, then -ddump-splices might be useful
• In the argument of reifyInstances: Fam_0
In the untyped splice:
$(do fam_name <- newName "Fam"
stringE . show =<< qReifyInstances fam_name [])
......@@ -389,5 +389,6 @@ test('T13618', normal, compile_and_run, ['-v0'])
test('T13642', normal, compile_fail, ['-v0'])
test('T13781', normal, compile, ['-v0'])
test('T13782', normal, compile, [''])
test('T13837', normal, compile_fail, ['-v0 -dsuppress-uniques'])
test('T13856', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('T13968', normal, compile_fail, ['-v0'])
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment