diff options
author | David Terei <code@davidterei.com> | 2015-05-11 16:05:37 -0700 |
---|---|---|
committer | David Terei <code@davidterei.com> | 2015-05-11 18:21:11 -0700 |
commit | 4fffbc34c024231c3c9fac7a2134896cc09c7fb7 (patch) | |
tree | a4b775d9f04997c2834303b2249dcae5ac42c642 /testsuite/tests/safeHaskell/ghci | |
parent | eecef1733d5de342383665943b955bc1c96472f4 (diff) | |
download | haskell-4fffbc34c024231c3c9fac7a2134896cc09c7fb7.tar.gz |
New handling of overlapping inst in Safe Haskell
We do much better now due to the newish per-instance flags. Rather than
mark any module that uses `-XOverlappingInstances`,
`-XIncoherentInstances` or the new `OVERLAP*` pragmas as unsafe, we
regard them all as safe and defer the check until an overlap occurs.
An type-class method call that involves overlapping instances is
considered _unsafe_ when:
1) The most specific instance, Ix, is from a module marked `-XSafe`
2) Ix is an orphan instance or a MPTC
3) At least one instance that Ix overlaps, Iy, is:
a) from a different module than Ix
AND
b) Iy is not marked `OVERLAPPABLE`
This check is only enforced in modules compiled with `-XSafe` or
`-XTrustworthy`.
This fixes Safe Haskell to work with the latest overlapping instance
pragmas, and also brings consistent behavior. Previously, Safe Inferred
modules behaved differently than `-XSafe` modules.
Diffstat (limited to 'testsuite/tests/safeHaskell/ghci')
-rw-r--r-- | testsuite/tests/safeHaskell/ghci/P13_A.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/safeHaskell/ghci/p13.stderr | 7 |
2 files changed, 3 insertions, 6 deletions
diff --git a/testsuite/tests/safeHaskell/ghci/P13_A.hs b/testsuite/tests/safeHaskell/ghci/P13_A.hs index 1044c83545..cfdb630464 100644 --- a/testsuite/tests/safeHaskell/ghci/P13_A.hs +++ b/testsuite/tests/safeHaskell/ghci/P13_A.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE OverlappingInstances, FlexibleInstances #-} +{-# LANGUAGE FlexibleInstances #-} module P13_A where class Pos a where { res :: a -> Bool } diff --git a/testsuite/tests/safeHaskell/ghci/p13.stderr b/testsuite/tests/safeHaskell/ghci/p13.stderr index 7a743f18eb..f7e8b8524b 100644 --- a/testsuite/tests/safeHaskell/ghci/p13.stderr +++ b/testsuite/tests/safeHaskell/ghci/p13.stderr @@ -1,8 +1,5 @@ -P13_A.hs:1:14: Warning: - -XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS - -<interactive>:11:1: +<interactive>:11:1: error: Unsafe overlapping instances for Pos [Int] arising from a use of ‘res’ The matching instance is: @@ -11,6 +8,6 @@ P13_A.hs:1:14: Warning: 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 [overlap ok] [safe] Pos [a] -- Defined at P13_A.hs:6:10 + instance [safe] Pos [a] -- Defined at P13_A.hs:6:10 In the expression: res [1 :: Int, 2 :: Int] In an equation for ‘it’: it = res [1 :: Int, 2 :: Int] |