[GHC] #12854: ghc-8 prints mangled names in error message: ‘GHC.Base.$dm<$’

#12854: ghc-8 prints mangled names in error message: ‘GHC.Base.$dm<$’ -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 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: -------------------------------------+------------------------------------- Noticed on old omega codebase when built with ghc-8.0.2-rc1. Here is the minimal example: {{{#!hs {-# LANGUAGE FlexibleInstances, KindSignatures #-} {-# OPTIONS_GHC -Wall #-} data F a b instance Functor (F a) where fmap = undefined instance Functor (F String) where fmap = undefined }}} {{{ $ ghci a.hs GHCi, version 8.0.1.20161117: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/slyfox/.ghci [1 of 1] Compiling Main ( a.hs, interpreted ) a.hs:6:10: error: • Overlapping instances for Functor (F String) arising from a use of ‘GHC.Base.$dm<$’ Matching instances: instance Functor (F a) -- Defined at a.hs:5:10 instance Functor (F String) -- Defined at a.hs:6:10 • In the expression: GHC.Base.$dm<$ @F String In an equation for ‘<$’: (<$) = GHC.Base.$dm<$ @F String In the instance declaration for ‘Functor (F String)’ Failed, modules loaded: none. }}} ‘GHC.Base.$dm<$’ is an internal name. Looks like it should be a 'GHC.Base.<$'. Confusingly this does not cause overlapping error at all: {{{#!hs {-# LANGUAGE FlexibleInstances, KindSignatures #-} {-# OPTIONS_GHC -Wall #-} data F a b class C (f :: * -> *) where instance C (F a) where instance C (F String) where }}} {{{ $ ghci a.hs GHCi, version 8.0.1.20161117: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/slyfox/.ghci [1 of 1] Compiling Main ( a.hs, interpreted ) Ok, modules loaded: Main. }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12854 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12854: ghc-8 prints mangled names in error message: ‘GHC.Base.$dm<$’ -------------------------------------+------------------------------------- Reporter: slyfox | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 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 simonpj): I can explain what is going on. I'm not so sure how to fix it. You don't get an overlapping error for your `C` declarations because you aren't ''using'' them. Class overlap is reported lazily; see the user manual. For the `Functor` declarations, since you omit the default method, we fill it in fo you {{{ instance Functor (F String) where fmap = undefined ($<) = $dm< @(F String) }}} The default method comes from the original class decl, which looked like this {{{ class Functor f where fmap :: (a -> b) -> f a -> f b (<$) :: a -> f b -> f a (<$) = fmap . const }}} From this we get {{{ $dm< :: Functor f => a -> f b -> f a }}} So, in the instance decl we get the constraint `Functor (F String)`. But we don't know which of the two instance decls to use to solve it, alas, hence the error. It's not very clear what a good error message would be; and even less clear how to achieve it! Perhaps some more explanation in the user manual, along the lines above, would be a stop-gap. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12854#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12854: ghc-8 prints mangled names in error message: ‘GHC.Base.$dm<$’ -------------------------------------+------------------------------------- Reporter: slyfox | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10087, #13755 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #10087, #13755 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12854#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC