[commit: ghc] master: Fix collect_lpat's treatment of HsSplicedPats (eaf9cc4)
git at git.haskell.org
git at git.haskell.org
Thu May 11 21:33:49 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/eaf9cc4240019c2e91922ef38ae7236b59d59bdd/ghc
>---------------------------------------------------------------
commit eaf9cc4240019c2e91922ef38ae7236b59d59bdd
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date: Thu May 11 15:46:02 2017 -0400
Fix collect_lpat's treatment of HsSplicedPats
`collect_lpat` was missing a case for `HsSplicedPat`, which caused
incorrect renaming of TH-spliced pattern variables.
Fixes #13473.
Test Plan: make test TEST=T13473
Reviewers: facundominguez, austin, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie
GHC Trac Issues: #13473
Differential Revision: https://phabricator.haskell.org/D3572
>---------------------------------------------------------------
eaf9cc4240019c2e91922ef38ae7236b59d59bdd
compiler/hsSyn/HsUtils.hs | 3 +++
testsuite/tests/th/T13473.hs | 13 +++++++++++++
.../{deSugar/should_run/T13285.stdout => th/T13473.stdout} | 0
testsuite/tests/th/T13473a.hs | 10 ++++++++++
testsuite/tests/th/all.T | 2 ++
5 files changed, 28 insertions(+)
diff --git a/compiler/hsSyn/HsUtils.hs b/compiler/hsSyn/HsUtils.hs
index 2b3a5c6..a15aa15 100644
--- a/compiler/hsSyn/HsUtils.hs
+++ b/compiler/hsSyn/HsUtils.hs
@@ -965,6 +965,9 @@ collect_lpat (L _ pat) bndrs
go (SigPatIn pat _) = collect_lpat pat bndrs
go (SigPatOut pat _) = collect_lpat pat bndrs
+
+ go (SplicePat (HsSpliced _ (HsSplicedPat pat)))
+ = go pat
go (SplicePat _) = bndrs
go (CoPat _ pat _) = go pat
diff --git a/testsuite/tests/th/T13473.hs b/testsuite/tests/th/T13473.hs
new file mode 100644
index 0000000..d977626
--- /dev/null
+++ b/testsuite/tests/th/T13473.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE QuasiQuotes #-}
+{-# LANGUAGE TemplateHaskell #-}
+module Main where
+
+import Language.Haskell.TH
+import T13473a
+
+[quoter|y|] = 1
+
+main :: IO ()
+main = do
+ let $(varP $ mkName "x") = 1 in print x
+ print y
diff --git a/testsuite/tests/deSugar/should_run/T13285.stdout b/testsuite/tests/th/T13473.stdout
similarity index 100%
copy from testsuite/tests/deSugar/should_run/T13285.stdout
copy to testsuite/tests/th/T13473.stdout
diff --git a/testsuite/tests/th/T13473a.hs b/testsuite/tests/th/T13473a.hs
new file mode 100644
index 0000000..fcd6ebb
--- /dev/null
+++ b/testsuite/tests/th/T13473a.hs
@@ -0,0 +1,10 @@
+module T13473a where
+
+import Language.Haskell.TH
+import Language.Haskell.TH.Quote
+
+quoter :: QuasiQuoter
+quoter = QuasiQuoter { quotePat = varP . mkName
+ , quoteExp = undefined
+ , quoteDec = undefined
+ , quoteType = undefined }
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index fd4530a..40e3b17 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -381,6 +381,8 @@ test('T13123', normal, compile, ['-v0'])
test('T13098', normal, compile, ['-v0'])
test('T11046', normal, multimod_compile, ['T11046','-v0'])
test('T13366', normal, compile_and_run, ['-lstdc++ -v0'])
+test('T13473', normal, multimod_compile_and_run,
+ ['T13473.hs', '-v0 ' + config.ghc_th_way_flags])
test('T13587', expect_broken(13587), compile_and_run, ['-v0'])
test('T13618', normal, compile_and_run, ['-v0'])
test('T13642', normal, compile_fail, ['-v0'])
More information about the ghc-commits
mailing list