[GHC] #16077: AvailTC Invariant being violated

#16077: AvailTC Invariant being violated -------------------------------------+------------------------------------- Reporter: harpocrates | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 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: -------------------------------------+------------------------------------- The `AvailTC Invariant` (from `basicTypes/Avail.hs`) states that: {{{ If the type or class is itself to be in scope, it must be *first* in this list. Thus, typically: @AvailTC Eq [Eq, ==, \/=]@ }}} Here is a case where this invariant is not upheld: * `pkgA/pkgA.cabal`: {{{ name: pkgA version: 1.0.0 build-type: Simple cabal-version: >= 1.2 library exposed-modules: A build-depends: base }}} * `pkgA/A.hs` {{{ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeFamilies #-} module A ( C(..) , T(TI) , error ) where class C a where data T a instance C Int where data T Int = TI { ti :: Int } }}} * `pkgB/pkgB.cabal` {{{ name: pkgB version: 1.0.0 build-type: Simple cabal-version: >= 1.2 library exposed-modules: B build-depends: base, pkgA }}} * `pkgB/B.hs` {{{ module B ( module A ) where import A hiding (error) }}} Now, check out the exports for `A` vs. `B`: {{{ $ cabal new-build pkgA pkgB --ghc-options -ddump-rn-trace | grep rnExports Warning: The package list for 'hackage.haskell.org' is 38 days old. Run 'cabal update' to get the latest list of available packages. rnExports: Exports: [error, C{C, T;}, T{T, TI;}] rnExports: Exports: [C{C, T;}, T{TI;}] }}} Why is `T{TI;}` in the second line not `T{T, TI;}`? Shouldn't the exports for `B` be identical to those for `A` (except for `error`)? This is causing a crash in Haddock: https://github.com/haskell/haddock/issues/979. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16077 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16077: AvailTC Invariant being violated -------------------------------------+------------------------------------- Reporter: harpocrates | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 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: | -------------------------------------+------------------------------------- Changes (by watashi): * cc: watashi (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16077#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16077: AvailTC Invariant being violated -------------------------------------+------------------------------------- Reporter: harpocrates | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 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 harpocrates): I've begun to investigate this and none of this actually requires `cabal`. Using `A.hs` and `B.hs` from the bug summary, just run {{{ $ ghc -fforce-recomp -ddump-rn-trace A.hs B.hs | grep rnExports rnExports: Exports: [error, C{C, T;}, T{T, TI;}] rnExports: Exports: [C{C, T;}, T{TI;}] }}} The asymmetry is pretty clear. Also, this is reproducible on HEAD. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16077#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16077: AvailTC Invariant being violated -------------------------------------+------------------------------------- Reporter: harpocrates | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.6.3 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: | https://gitlab.haskell.org/ghc/ghc/merge_requests/276 -------------------------------------+------------------------------------- Changes (by harpocrates): * status: new => patch * differential: => https://gitlab.haskell.org/ghc/ghc/merge_requests/276 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16077#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16077: AvailTC Invariant being violated
-------------------------------------+-------------------------------------
Reporter: harpocrates | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 8.6.3
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: | https://gitlab.haskell.org/ghc/ghc/merge_requests/276
-------------------------------------+-------------------------------------
Comment (by Alec Theriault
participants (1)
-
GHC