summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2021-02-15 10:52:42 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-17 11:22:58 -0500
commitdbf8f6fe12db67b96412015a01646ce800f9988a (patch)
treee498479cfae374b07399615938e6bda5829c6487 /testsuite/tests
parenta70bab97a0617bb9516b65d1d211b5e26ab51641 (diff)
downloadhaskell-dbf8f6fe12db67b96412015a01646ce800f9988a.tar.gz
Fix #19377 by using lookupLOcc when desugaring TH-quoted ANNs
Previously, the desugarer was looking up names referenced in TH-quoted `ANN`s by using `globalVar`, which would allocate a fresh TH `Name`. In effect, this would prevent quoted `ANN`s from ever referencing the correct identifier `Name`, leading to #19377. The fix is simple: instead of `globalVar`, use `lookupLOcc`, which properly looks up the name of the in-scope identifier. Fixes #19377.
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/th/T19377.hs10
-rw-r--r--testsuite/tests/th/all.T1
2 files changed, 11 insertions, 0 deletions
diff --git a/testsuite/tests/th/T19377.hs b/testsuite/tests/th/T19377.hs
new file mode 100644
index 0000000000..e27149ccfe
--- /dev/null
+++ b/testsuite/tests/th/T19377.hs
@@ -0,0 +1,10 @@
+{-# LANGUAGE TemplateHaskell #-}
+module T19377 where
+
+$([d| x :: Int
+ x = 42
+ {-# ANN x "blah" #-}
+
+ data Y
+ {-# ANN type Y "yargh" #-}
+ |])
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 3dc58ea302..866bbdef31 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -518,3 +518,4 @@ test('T18388', normal, compile, [''])
test('T18612', normal, compile, [''])
test('T18740c', normal, compile_fail, [''])
test('T18740d', normal, compile_fail, [''])
+test('T19377', normal, compile, [''])