[commit: ghc] ghc-8.2: Fix collect_lpat's treatment of HsSplicedPats (72015ab)

git at git.haskell.org git at git.haskell.org
Tue May 16 01:12:12 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/72015aba0af37e0547150299049591e2a0ced270/ghc

>---------------------------------------------------------------

commit 72015aba0af37e0547150299049591e2a0ced270
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
    
    (cherry picked from commit eaf9cc4240019c2e91922ef38ae7236b59d59bdd)


>---------------------------------------------------------------

72015aba0af37e0547150299049591e2a0ced270
 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 c7d43b0..d19e45b 100644
--- a/compiler/hsSyn/HsUtils.hs
+++ b/compiler/hsSyn/HsUtils.hs
@@ -958,6 +958,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 4037a8f..06fbdcd 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -381,5 +381,7 @@ 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('T13618', normal, compile_and_run, ['-v0'])
 test('T13642', normal, compile_fail, ['-v0'])



More information about the ghc-commits mailing list