[GHC] #13069: hs-boot files permit default methods in type class

#13069: hs-boot files permit default methods in type class -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.1 (Type checker) | Keywords: backpack hs- | Operating System: Unknown/Multiple boot | Architecture: | Type of failure: GHC accepts Unknown/Multiple | invalid program Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- The documentation claims you are not allowed to do so but the compiler does not reject it. {{{ ezyang@sabre:~$ cat A.hs-boot module A where class C a where f :: a -> a f x = x ezyang@sabre:~$ ghc-head -c A.hs-boot -fforce-recomp ezyang@sabre:~$ ghc-head --version The Glorious Glasgow Haskell Compilation System, version 8.1.20161218 }}} The same problem applies to hsig files (which combust more spectacularly) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13069 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13069: hs-boot files permit default methods in type class -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Keywords: backpack hs- Resolution: | boot 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: | -------------------------------------+------------------------------------- Comment (by ezyang): It looks like some hs-boot files have come to rely on this behavior: {{{ MiniAgda-0.2014.9.12/Eval.hs-boot:class Reval a where MiniAgda-0.2014.9.12/Eval.hs-boot- reval' :: Valuation -> a -> TypeCheck a MiniAgda-0.2014.9.12/Eval.hs-boot- reval :: a -> TypeCheck a MiniAgda-0.2014.9.12/Eval.hs-boot- reval = reval' emptyVal postgresql-simple-0.5.2.1/src/Database/PostgreSQL/Simple/ToRow.hs- boot:class ToRow a where postgresql-simple-0.5.2.1/src/Database/PostgreSQL/Simple/ToRow.hs-boot- toRow :: a -> [Action] postgresql-simple-0.5.2.1/src/Database/PostgreSQL/Simple/ToRow.hs-boot- default toRow :: (Generic a, GToRow (Rep a)) => a -> [Action] postgresql-simple-0.5.2.1/src/Database/PostgreSQL/Simple/ToRow.hs-boot- toRow = gtoRow . from event-monad-0.0.3/src/Control/Monad/Event/Classes.hs-boot:class (MonadEvent m e, MonadTime m t) => ScheduleEvent m t e | m -> t event-monad-0.0.3/src/Control/Monad/Event/Classes.hs-boot- where event-monad-0.0.3/src/Control/Monad/Event/Classes.hs-boot- scheduleEventAt :: t -> e -> m EventID event-monad-0.0.3/src/Control/Monad/Event/Classes.hs-boot- doNext :: e -> m () event-monad-0.0.3/src/Control/Monad/Event/Classes.hs-boot- doNext e = do event-monad-0.0.3/src/Control/Monad/Event/Classes.hs-boot- now <- getCurrentTime event-monad-0.0.3/src/Control/Monad/Event/Classes.hs-boot- scheduleEventAt now e }}} Maybe less than a dozen I could see on Hackage. So maybe we should just update the docs. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13069#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13069: hs-boot files permit default methods in type class -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Keywords: backpack hs- Resolution: | boot 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: | -------------------------------------+------------------------------------- Comment (by ezyang): Actually, the bug is worse: the following A.hs-boot file is accepted by GHC. {{{ module A where class C a where f :: a -> a f = True }}} This doesn't seem to be a soundness problem because what this actually seems to translate into "there is a default method for f", so this code never gets compiled / used for anything. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13069#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13069: hs-boot files permit default methods in type class (but don't typecheck them) -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.1 checker) | Keywords: backpack hs- Resolution: | boot 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: | -------------------------------------+------------------------------------- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13069#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13069: hs-boot files permit default methods in type class (but don't typecheck them) -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.1 checker) | Keywords: backpack hs- Resolution: | boot 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/13069#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13069: hs-boot files permit default methods in type class (but don't typecheck them) -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.1 checker) | Keywords: backpack hs- Resolution: | boot 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: | -------------------------------------+------------------------------------- Comment (by ezyang): The corresponding version of this bug with hsig files was fixed with #13041. So it's just an hs-boot bug now. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13069#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC