[commit: ghc] master: Add in Incoherent Instances test for Safe Haskell. (c96a613)

git at git.haskell.org git at git.haskell.org
Thu Nov 6 19:20:53 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c96a613c98d07fab4facc77bdd0701b7a17d332a/ghc

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

commit c96a613c98d07fab4facc77bdd0701b7a17d332a
Author: David Terei <code at davidterei.com>
Date:   Mon Aug 4 17:41:54 2014 -0400

    Add in Incoherent Instances test for Safe Haskell.


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

c96a613c98d07fab4facc77bdd0701b7a17d332a
 .../safeInfered/{UnsafeInfered15.hs => UnsafeInfered17.hs} |  2 +-
 .../tests/safeHaskell/safeInfered/UnsafeInfered17.stderr   |  9 +++++++++
 testsuite/tests/safeHaskell/safeInfered/all.T              |  1 +
 .../safeLanguage/{SafeLang10.hs => SafeLang17.hs}          |  4 ++--
 .../safeLanguage/{SafeLang10.stderr => SafeLang17.stderr}  | 14 +++++++-------
 .../safeLanguage/{SafeLang10_A.hs => SafeLang17_A.hs}      |  5 ++---
 .../safeLanguage/{SafeLang09_B.hs => SafeLang17_B.hs}      |  7 ++++---
 testsuite/tests/safeHaskell/safeLanguage/all.T             |  5 +++++
 8 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered15.hs b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered17.hs
similarity index 80%
copy from testsuite/tests/safeHaskell/safeInfered/UnsafeInfered15.hs
copy to testsuite/tests/safeHaskell/safeInfered/UnsafeInfered17.hs
index 427c97b..04591b5 100644
--- a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered15.hs
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered17.hs
@@ -5,6 +5,6 @@ module UnsafeInfered15 where
 class C a where
   f :: a -> String
 
-instance {-# OVERLAPPING #-} C a where
+instance {-# INCOHERENT #-} C a where
   f _ = "a"
 
diff --git a/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered17.stderr b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered17.stderr
new file mode 100644
index 0000000..415e9a1
--- /dev/null
+++ b/testsuite/tests/safeHaskell/safeInfered/UnsafeInfered17.stderr
@@ -0,0 +1,9 @@
+
+UnsafeInfered17.hs:1:16: Warning:
+    ‘UnsafeInfered15’ has been inferred as unsafe!
+    Reason:
+        UnsafeInfered17.hs:8:29:
+            [incoherent] overlap mode isn't allowed in Safe Haskell
+
+<no location info>: 
+Failing due to -Werror.
diff --git a/testsuite/tests/safeHaskell/safeInfered/all.T b/testsuite/tests/safeHaskell/safeInfered/all.T
index a9600fa..4fc9fce 100644
--- a/testsuite/tests/safeHaskell/safeInfered/all.T
+++ b/testsuite/tests/safeHaskell/safeInfered/all.T
@@ -64,6 +64,7 @@ test('UnsafeInfered13', normal, compile_fail, [''])
 test('UnsafeInfered14', normal, compile_fail, [''])
 test('UnsafeInfered15', normal, compile_fail, [''])
 test('UnsafeInfered16', normal, compile_fail, [''])
+test('UnsafeInfered17', normal, compile_fail, [''])
 
 # Mixed tests
 test('Mixed01', normal, compile_fail, [''])
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang10.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang17.hs
similarity index 66%
copy from testsuite/tests/safeHaskell/safeLanguage/SafeLang10.hs
copy to testsuite/tests/safeHaskell/safeLanguage/SafeLang17.hs
index 5c88d39..411addd 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang10.hs
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang17.hs
@@ -1,8 +1,8 @@
 {-# LANGUAGE Trustworthy #-}
 module Main where
 
-import safe SafeLang10_A -- trusted lib
-import safe SafeLang10_B -- untrusted plugin
+import SafeLang17_A -- trusted lib
+import SafeLang17_B -- untrusted plugin
 
 main = do
     let r = res [(1::Int)]
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang10.stderr b/testsuite/tests/safeHaskell/safeLanguage/SafeLang17.stderr
similarity index 58%
copy from testsuite/tests/safeHaskell/safeLanguage/SafeLang10.stderr
copy to testsuite/tests/safeHaskell/safeLanguage/SafeLang17.stderr
index d0c5c68..c59f866 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang10.stderr
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang17.stderr
@@ -1,17 +1,17 @@
-[1 of 3] Compiling SafeLang10_A     ( SafeLang10_A.hs, SafeLang10_A.o )
-[2 of 3] Compiling SafeLang10_B     ( SafeLang10_B.hs, SafeLang10_B.o )
-[3 of 3] Compiling Main             ( SafeLang10.hs, SafeLang10.o )
+[1 of 3] Compiling SafeLang17_A     ( SafeLang17_A.hs, SafeLang17_A.o )
+[2 of 3] Compiling SafeLang17_B     ( SafeLang17_B.hs, SafeLang17_B.o )
+[3 of 3] Compiling Main             ( SafeLang17.hs, SafeLang17.o )
 
-SafeLang10.hs:8:13:
+SafeLang17.hs:8:13:
     Unsafe overlapping instances for Pos [Int]
       arising from a use of ‘res’
     The matching instance is:
-      instance [overlapping] [safe] Pos [Int]
-        -- Defined at SafeLang10_B.hs:13:30
+      instance [incoherent] [safe] Pos [Int]
+        -- Defined at SafeLang17_B.hs:14:10
     It is compiled in a Safe module and as such can only
     overlap instances from the same module, however it
     overlaps the following instances from different modules:
-      instance Pos [a] -- Defined at SafeLang10_A.hs:13:10
+      instance Pos [a] -- Defined at SafeLang17_A.hs:13:10
     In the expression: res [(1 :: Int)]
     In an equation for ‘r’: r = res [(1 :: Int)]
     In the expression:
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang10_A.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang17_A.hs
similarity index 92%
copy from testsuite/tests/safeHaskell/safeLanguage/SafeLang10_A.hs
copy to testsuite/tests/safeHaskell/safeLanguage/SafeLang17_A.hs
index 7be17b5..0ce2bdf 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang10_A.hs
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang17_A.hs
@@ -1,8 +1,8 @@
-{-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE FlexibleInstances #-}
 
 -- | Trusted library that unsafe plugins can use
-module SafeLang10_A where
+module SafeLang17_A where
 
 class Pos a where
     res :: a -> Bool
@@ -13,4 +13,3 @@ class Pos a where
 instance Pos [a] where
     res _ = True
 
-
diff --git a/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_B.hs b/testsuite/tests/safeHaskell/safeLanguage/SafeLang17_B.hs
similarity index 70%
copy from testsuite/tests/safeHaskell/safeLanguage/SafeLang09_B.hs
copy to testsuite/tests/safeHaskell/safeLanguage/SafeLang17_B.hs
index d03a629..2059f01 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/SafeLang09_B.hs
+++ b/testsuite/tests/safeHaskell/safeLanguage/SafeLang17_B.hs
@@ -1,11 +1,12 @@
+{-# LANGUAGE Safe #-}
 {-# LANGUAGE FlexibleInstances #-}
-{-# LANGUAGE OverlappingInstances #-}
+{-# LANGUAGE IncoherentInstances #-}
 
 -- Untrusted plugin! Don't wan't it changing behaviour of our
 -- trusted code
-module SafeLang09_B where
+module SafeLang17_B where
 
-import SafeLang09_A
+import SafeLang17_A
 
 instance Pos a where
     res _ = False
diff --git a/testsuite/tests/safeHaskell/safeLanguage/all.T b/testsuite/tests/safeHaskell/safeLanguage/all.T
index 131778b..926c576 100644
--- a/testsuite/tests/safeHaskell/safeLanguage/all.T
+++ b/testsuite/tests/safeHaskell/safeLanguage/all.T
@@ -45,6 +45,11 @@ test('SafeLang15',
      multimod_compile_and_run,
      ['SafeLang15', '-XSafe'])
 test('SafeLang16', normal, compile, [''])
+test('SafeLang17',
+     extra_clean(['SafeLang17_A.o', 'SafeLang17_A.hi',
+                  'SafeLang17_B.o', 'SafeLang17_B.hi']),
+     multimod_compile_fail,
+     ['SafeLang17', ''])
 
 # Test building a package, that trust values are set correctly
 # and can be changed correctly



More information about the ghc-commits mailing list