Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsafeOverlap -> 36705 #187

Open
PPKFS opened this issue Jun 14, 2022 · 1 comment
Open

UnsafeOverlap -> 36705 #187

PPKFS opened this issue Jun 14, 2022 · 1 comment

Comments

@PPKFS
Copy link
Collaborator

PPKFS commented Jun 14, 2022

No description provided.

@david-christiansen david-christiansen transferred this issue from haskell/error-messages Jun 21, 2022
@BinderDavid
Copy link
Collaborator

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])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants