[GHC] #10990: Checking whether a default declaration is an instance of a defaultable typeclass is broken

#10990: Checking whether a default declaration is an instance of a defaultable typeclass is broken -------------------------------------+------------------------------------- Reporter: kanetw | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.10.2 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In TcDefaults.hs, `tcDefaults` is supposed to check whether the supplied default type is an instance o `Num` or `IsString` (note the lack of extended defaults here, so this has been broken for quite some time). Following the code we can see that `simplifyDefault` in TcSimplify.hs calls `reportAllUnsolved` and it does report the error -- with typechecker tracing on we see {{{ Adding error: <interactive>:19:1: error: No instance for (Num []) arising from a 'default' declaration When checking the types in a default declaration }}} But typechecking never actually fails, so it returns `Just ()` regardless and the error gets swallowed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10990 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10990: Checking whether a default declaration is an instance of a defaultable typeclass is broken -------------------------------------+------------------------------------- Reporter: kanetw | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): Could you add sample code please (if you're not working on a fix already). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10990#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10990: Checking whether a default declaration is an instance of a defaultable typeclass is broken -------------------------------------+------------------------------------- Reporter: kanetw | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by kanetw): Sure. {{{ % ./inplace/bin/ghc-stage2 --interactive -dtrace-level1 -ddump-tc-trace
default (Maybe Int) ... Adding error: <interactive>:1:1: error: No instance for (Num (Maybe Int)) arising from a 'default' declaration When checking the types in a default declaration ... }}}.
I might do a fix for this after I finish #10971. It's not a huge problem, but if we don't check for default declaration validity (which might be useful with a possible #10972 implementation) we should adjust the code/document it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10990#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10990: Checking whether a default declaration is an instance of a defaultable typeclass is broken -------------------------------------+------------------------------------- Reporter: kanetw | Owner: (none) Type: bug | Status: closed Priority: low | Milestone: Component: Compiler (Type | Version: 7.10.2 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by harpocrates): * status: new => closed * resolution: => fixed Comment: Fixed in 9a34bf1985035858ece043bf38b47b6ff4b88efb (I think, although I haven't compiled before and after to check). At the very least, that commit added test cases demonstrating this to be solved. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10990#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC