[GHC] #13068: GHC should not allow modules to define instances of abstract type classes

#13068: GHC should not allow modules to define instances of abstract type classes -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 8.1 (Type checker) | Keywords: backpack | 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-boot files permit a type class to be given "abstractly", in which case any implementation of the type class is permissible. But it does not reject instances defined for such a class. {{{ -- A.hs-boot module A where class C a -- B.hs module B where import {-# SOURCE #-} A instance C Int where -- A.hs module A where import B class C a where f :: a -- Main.hs import A main = print (f :: Int) }}} I get this when I build with `--make`: {{{ ezyang@sabre:~$ ghc-head --make C.hs -fforce-recomp [1 of 4] Compiling A[boot] ( A.hs-boot, A.o-boot ) [2 of 4] Compiling B ( B.hs, B.o ) [3 of 4] Compiling A ( A.hs, A.o ) [4 of 4] Compiling Main ( C.hs, C.o ) Linking C ... ./B.o:(.data+0x0): undefined reference to `A_CZCC_con_info' collect2: error: ld returned 1 exit status }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13068 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13068: GHC should not allow modules to define instances of abstract type classes -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: low | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.1 checker) | Resolution: | Keywords: backpack 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 dfeuer): * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13068#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13068: GHC should not allow modules to define instances of abstract type classes -------------------------------------+------------------------------------- Reporter: ezyang | Owner: (none) Type: bug | Status: patch Priority: low | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.1 checker) | Resolution: | Keywords: backpack Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3254 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => patch * differential: => Phab:D3254 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13068#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13068: GHC should not allow modules to define instances of abstract type classes
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: (none)
Type: bug | Status: patch
Priority: low | Milestone: 8.2.1
Component: Compiler (Type | Version: 8.1
checker) |
Resolution: | Keywords: backpack
Operating System: Unknown/Multiple | Architecture:
Type of failure: GHC accepts | Unknown/Multiple
invalid program | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3254
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Edward Z. Yang

#13068: GHC should not allow modules to define instances of abstract type classes -------------------------------------+------------------------------------- Reporter: ezyang | Owner: (none) Type: bug | Status: closed Priority: low | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.1 checker) | Resolution: fixed | Keywords: backpack Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3254 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Old description:
hs-boot files permit a type class to be given "abstractly", in which case any implementation of the type class is permissible. But it does not reject instances defined for such a class.
{{{ -- A.hs-boot module A where class C a
-- B.hs module B where import {-# SOURCE #-} A instance C Int where
-- A.hs module A where import B class C a where f :: a
-- Main.hs import A main = print (f :: Int) }}}
I get this when I build with `--make`:
{{{ ezyang@sabre:~$ ghc-head --make C.hs -fforce-recomp [1 of 4] Compiling A[boot] ( A.hs-boot, A.o-boot ) [2 of 4] Compiling B ( B.hs, B.o ) [3 of 4] Compiling A ( A.hs, A.o ) [4 of 4] Compiling Main ( C.hs, C.o ) Linking C ... ./B.o:(.data+0x0): undefined reference to `A_CZCC_con_info' collect2: error: ld returned 1 exit status }}}
New description: hs-boot files permit a type class to be given "abstractly", in which case any implementation of the type class is permissible. But it does not reject instances defined for such a class. {{{#!hs -- A.hs-boot module A where class C a -- B.hs module B where import {-# SOURCE #-} A instance C Int where -- A.hs module A where import B class C a where f :: a -- Main.hs import A main = print (f :: Int) }}} I get this when I build with `--make`: {{{ ezyang@sabre:~$ ghc-head --make C.hs -fforce-recomp [1 of 4] Compiling A[boot] ( A.hs-boot, A.o-boot ) [2 of 4] Compiling B ( B.hs, B.o ) [3 of 4] Compiling A ( A.hs, A.o ) [4 of 4] Compiling Main ( C.hs, C.o ) Linking C ... ./B.o:(.data+0x0): undefined reference to `A_CZCC_con_info' collect2: error: ld returned 1 exit status }}} -- Comment: This was resolved in bba004f2a0642d3bb8c8876543aaa1a48a2f9a43. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13068#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC