[commit: ghc] master: Add a broken test for lingering state from TH unique names #9693 (fbe162f)
git at git.haskell.org
git at git.haskell.org
Fri Jul 6 18:09:39 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/fbe162f58caa31df445d9edbf0b0919810687011/ghc
>---------------------------------------------------------------
commit fbe162f58caa31df445d9edbf0b0919810687011
Author: Michael Sloan <mgsloan at gmail.com>
Date: Fri Jul 6 11:00:10 2018 -0400
Add a broken test for lingering state from TH unique names #9693
The stderr output is
```
Loading with T9693_initial.hs
T9693_main.hs:4:1:
Same exact name in multiple name-spaces:
type constructor or class ‘X’, declared at: T9693_main.hs:4:1
data constructor ‘X’, declared at: T9693_main.hs:4:1
Probable cause: you bound a unique Template Haskell name (NameU),
perhaps via newName, in different name-spaces.
If that's it, then -ddump-splices might be useful
Reloading with T9693_modified.hs
T9693_main.hs:1:1:
Data constructor ‘X’ used as a type constructor
```
The strange thing is that the modified version uses (mkName "X"), which should
be fine for simultaneous use in both a data constructor and type constructor.
Indeed, on a fresh load, the modified version works fine. So there is some sort
of state left over from the prior load when (newName "X") was used.
Test Plan: testsuite/tests/th/T9693.script
Reviewers: bgamari, sighingnow, RyanGlScott
Reviewed By: sighingnow, RyanGlScott
Subscribers: RyanGlScott, sighingnow, rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4926
>---------------------------------------------------------------
fbe162f58caa31df445d9edbf0b0919810687011
testsuite/tests/th/T9693.script | 7 +++++++
testsuite/tests/th/T9693_initial.hs | 9 +++++++++
testsuite/tests/th/{should_compile/T8025/A.hs => T9693_main.hs} | 5 +++--
testsuite/tests/th/T9693_modified.hs | 9 +++++++++
testsuite/tests/th/all.T | 2 ++
5 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/testsuite/tests/th/T9693.script b/testsuite/tests/th/T9693.script
new file mode 100644
index 0000000..99643e7
--- /dev/null
+++ b/testsuite/tests/th/T9693.script
@@ -0,0 +1,7 @@
+System.Directory.copyFile "T9693_initial.hs" "T9693.hs"
+System.IO.hPutStrLn System.IO.stderr "Loading with T9693_initial.hs"
+:load T9693_main.hs
+System.Directory.copyFile "T9693_modified.hs" "T9693.hs"
+System.IO.hPutStrLn System.IO.stderr "Reloading with T9693_modified.hs"
+:reload
+System.Directory.removeFile "T9693.hs"
diff --git a/testsuite/tests/th/T9693_initial.hs b/testsuite/tests/th/T9693_initial.hs
new file mode 100644
index 0000000..b646f0e
--- /dev/null
+++ b/testsuite/tests/th/T9693_initial.hs
@@ -0,0 +1,9 @@
+module T9693 where
+import Language.Haskell.TH
+
+stuff = do
+ -- let x = mkName "X"
+ x <- newName "X"
+ sequence $ [dataD (return []) x [] Nothing [
+ normalC x []
+ ] []]
diff --git a/testsuite/tests/th/should_compile/T8025/A.hs b/testsuite/tests/th/T9693_main.hs
similarity index 56%
copy from testsuite/tests/th/should_compile/T8025/A.hs
copy to testsuite/tests/th/T9693_main.hs
index c0e3083..71e7c9a 100644
--- a/testsuite/tests/th/should_compile/T8025/A.hs
+++ b/testsuite/tests/th/T9693_main.hs
@@ -1,3 +1,4 @@
{-# LANGUAGE TemplateHaskell #-}
-module A where
-a = [|3|]
+import T9693
+
+stuff
diff --git a/testsuite/tests/th/T9693_modified.hs b/testsuite/tests/th/T9693_modified.hs
new file mode 100644
index 0000000..cab2c04
--- /dev/null
+++ b/testsuite/tests/th/T9693_modified.hs
@@ -0,0 +1,9 @@
+module T9693 where
+import Language.Haskell.TH
+
+stuff = do
+ let x = mkName "X"
+ -- x <- newName "X"
+ sequence $ [dataD (return []) x [] Nothing [
+ normalC x []
+ ] []]
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 84aa84b..e147491 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -418,3 +418,5 @@ test('T15243', normal, compile, ['-dsuppress-uniques'])
test('T15321', normal, compile_fail, [''])
test('T15324', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
test('T15331', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
+# Note: T9693 should be only_ways(['ghci']) once it's fixed.
+test('T9693', expect_broken(9693), ghci_script, ['T9693.script'])
More information about the ghc-commits
mailing list