summaryrefslogtreecommitdiff
path: root/libraries/template-haskell
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-12-22 10:59:16 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-24 00:42:51 -0500
commit6d62f6bfbb5a86131e7cbc30993f3fa510d8b3ab (patch)
treee888f791533511ce762e8768ba4790772c3b7ce7 /libraries/template-haskell
parentf42ba88fd32f1def7dcf02f0a2227b453bf5971c (diff)
downloadhaskell-6d62f6bfbb5a86131e7cbc30993f3fa510d8b3ab.tar.gz
Store RdrName rather than OccName in Holes
In #20472 it was pointed out that you couldn't defer out of scope but the implementation collapsed a RdrName into an OccName to stuff it into a Hole. This leads to the error message for a deferred qualified name dropping the qualification which affects the quality of the error message. This commit adds a bit more structure to a hole, so a hole can replace a RdrName without losing information about what that RdrName was. This is important when printing error messages. I also added a test which checks the Template Haskell deferral of out of scope qualified names works properly. Fixes #22130
Diffstat (limited to 'libraries/template-haskell')
-rw-r--r--libraries/template-haskell/Language/Haskell/TH/Syntax.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
index 30958c5cbe..0304eb130b 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
@@ -1807,6 +1807,10 @@ mkNameU s u = Name (mkOccName s) (NameU u)
mkNameL :: String -> Uniq -> Name
mkNameL s u = Name (mkOccName s) (NameL u)
+-- | Only used internally
+mkNameQ :: String -> String -> Name
+mkNameQ mn occ = Name (mkOccName occ) (NameQ (mkModName mn))
+
-- | Used for 'x etc, but not available to the programmer
mkNameG :: NameSpace -> String -> String -> String -> Name
mkNameG ns pkg modu occ