[GHC] #11674: GHC accepts overly general instance sigs

#11674: GHC accepts overly general instance sigs -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 Keywords: InstanceSigs | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC accepts Unknown/Multiple | invalid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- {{{#!hs {-# LANGUAGE InstanceSigs #-} data I a = MkI a instance Functor I where fmap :: (a -> b) -> f a -> f b fmap = undefined }}} is accepted when the type is too general, even things like: {{{#!hs fmap :: (a -> b) -> f a -> g b -- & fmap :: whoami }}} are accepted -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11674 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11674: GHC accepts overly general instance sigs -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.1 Resolution: invalid | Keywords: InstanceSigs Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: That's fine. It's equivalent to this {{{ instance Functor I where fmap = fmapI fmapI :: (a -> b) -> f a -> f b fmapI = undefined }}} So we check (a) that the defined function has the specified type, and (b) that a function of the specified type is acceptable in the instance decl. See 9.7.3.7 under http://downloads.haskell.org/~ghc/master/users- guide/glasgow_exts.html#instance-declarations. If the documentation should be clearer, could you suggest alternative wording that would have made it clearer? Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11674#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC