[commit: ghc] ghc-7.8: Small issue with signatures in a TH splice (fixes Trac #8932) (e2e6d12)

git at git.haskell.org git at git.haskell.org
Tue Apr 22 06:08:55 UTC 2014


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

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/e2e6d122e1c7f6cdcf2483379bfa7c5acb1022a1/ghc

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

commit e2e6d122e1c7f6cdcf2483379bfa7c5acb1022a1
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon Apr 7 15:22:11 2014 +0100

    Small issue with signatures in a TH splice (fixes Trac #8932)
    
    (cherry picked from commit d8d798b1b33ab0593ed03f193360b8725ba2c2ba)
    
    Conflicts:
    	testsuite/tests/th/all.T


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

e2e6d122e1c7f6cdcf2483379bfa7c5acb1022a1
 compiler/rename/RnEnv.lhs       |   12 ++++++++++--
 testsuite/tests/th/T8932.hs     |   12 ++++++++++++
 testsuite/tests/th/T8932.stderr |    5 +++++
 testsuite/tests/th/all.T        |    1 +
 4 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/compiler/rename/RnEnv.lhs b/compiler/rename/RnEnv.lhs
index 150b8ce..cfd1f48 100644
--- a/compiler/rename/RnEnv.lhs
+++ b/compiler/rename/RnEnv.lhs
@@ -270,8 +270,16 @@ lookupExactOcc name
                        ; return name
                        }
 
-           [gre] -> return (gre_name gre)
-           _     -> pprPanic "lookupExactOcc" (ppr name $$ ppr gres) }
+           (gre:_) -> return (gre_name gre) }
+           -- We can get more than one GRE here, if there are multiple 
+           -- bindings for the same name; but there will already be a 
+           -- reported error for the duplicate.  (If we add the error 
+           -- rather than stopping when we encounter it.) 
+           -- So all we need do here is not crash.  
+           -- Example is Trac #8932:
+           --    $( [d| foo :: a->a; foo x = x |])
+           --    foo = True
+           -- Here the 'foo' in the splice turns into an Exact Name
 
   where
     exact_nm_err = hang (ptext (sLit "The exact Name") <+> quotes (ppr name) <+> ptext (sLit "is not in scope"))
diff --git a/testsuite/tests/th/T8932.hs b/testsuite/tests/th/T8932.hs
new file mode 100644
index 0000000..05630f3
--- /dev/null
+++ b/testsuite/tests/th/T8932.hs
@@ -0,0 +1,12 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module T8932 where
+
+$([d|
+   foo :: a -> a
+   foo x = x
+  |])
+
+foo :: a
+foo = undefined
+
diff --git a/testsuite/tests/th/T8932.stderr b/testsuite/tests/th/T8932.stderr
new file mode 100644
index 0000000..0e0f977
--- /dev/null
+++ b/testsuite/tests/th/T8932.stderr
@@ -0,0 +1,5 @@
+
+T8932.hs:11:1:
+    Multiple declarations of ‘foo’
+    Declared at: T8932.hs:5:3
+                 T8932.hs:11:1
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index c39fc6d..4117cf1 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -320,3 +320,4 @@ test('T8625', normal, ghci_script, ['T8625.script'])
 test('T8759', normal, compile_fail, ['-v0'])
 test('T8759a', normal, compile_fail, ['-v0'])
 test('T8884', normal, compile, ['-v0'])
+test('T8932', normal, compile_fail, ['-v0'])



More information about the ghc-commits mailing list