diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2014-04-07 15:22:11 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2014-04-07 15:25:24 +0100 |
commit | d8d798b1b33ab0593ed03f193360b8725ba2c2ba (patch) | |
tree | 4ab080437f040ebf263f154663ad3787ce01da6a | |
parent | 8f831ec578d22419788542290e164c50524d90f6 (diff) | |
download | haskell-d8d798b1b33ab0593ed03f193360b8725ba2c2ba.tar.gz |
Small issue with signatures in a TH splice (fixes Trac #8932)
-rw-r--r-- | compiler/rename/RnEnv.lhs | 12 | ||||
-rw-r--r-- | testsuite/tests/th/T8932.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/th/T8932.stderr | 5 | ||||
-rw-r--r-- | 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 49cbbad13d..178f722d99 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 0000000000..05630f331f --- /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 0000000000..0e0f9774d5 --- /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 19cc2e42b8..ce723dd304 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']) + |