error-message-index
error-message-index copied to clipboard
UnsafeOverlap -> 36705
Example from the GHC testsuite:
{-# LANGUAGE Haskell2010 #-}
{-# OPTIONS_GHC -fwarn-unsafe #-}
{-# LANGUAGE FlexibleInstances #-}
module SH_Overlap6_A (
C(..)
) where
import SH_Overlap6_B
instance
{-# OVERLAPS #-}
C [Int] where
f _ = "[Int]"
and
{-# LANGUAGE Haskell2010 #-}
{-# OPTIONS_GHC -fwarn-unsafe #-}
module SH_Overlap6_B (
C(..)
) where
class C a where
f :: a -> String
and
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE Safe #-}
{-# LANGUAGE FlexibleInstances #-}
-- | Same as `SH_Overlap5` but dependencies are now inferred-safe, not
-- explicitly marked. Compilation should still fail.
module SH_Overlap6 where
import safe SH_Overlap6_A
instance C [a] where
f _ = "[a]"
test :: String
test = f ([1,2,3,4] :: [Int])
creates the following message:
SH_Overlap6.hs:15:8: error: [GHC-36705]
• Unsafe overlapping instances for C [Int]
arising from a use of ‘f’
The matching instance is:
instance [overlap ok] [safe] C [Int]
-- Defined at SH_Overlap6_A.hs:12:3
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 [safe] C [a] -- Defined at SH_Overlap6.hs:11:10
• In the expression: f ([1, 2, 3, 4] :: [Int])
In an equation for ‘test’: test = f ([1, 2, 3, 4] :: [Int])