[commit: ghc] master: Small issue with signatures in a TH splice (fixes Trac #8932) (d8d798b)
git at git.haskell.org
git at git.haskell.org
Mon Apr 7 14:25:32 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/d8d798b1b33ab0593ed03f193360b8725ba2c2ba/ghc
>---------------------------------------------------------------
commit d8d798b1b33ab0593ed03f193360b8725ba2c2ba
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)
>---------------------------------------------------------------
d8d798b1b33ab0593ed03f193360b8725ba2c2ba
compiler/rename/RnEnv.lhs | 12 ++++++++++--
testsuite/tests/th/T8932.hs | 12 ++++++++++++
testsuite/tests/th/T8932.stderr | 5 +++++
testsuite/tests/th/all.T | 2 ++
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/compiler/rename/RnEnv.lhs b/compiler/rename/RnEnv.lhs
index 49cbbad..178f722 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 19cc2e4..ce723dd 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -324,3 +324,5 @@ test('T7021',
test('T8807', normal, compile, ['-v0'])
test('T8884', normal, compile, ['-v0'])
test('T8954', normal, compile, ['-v0'])
+test('T8932', normal, compile_fail, ['-v0'])
+
More information about the ghc-commits
mailing list