Explicit namespaces doesn't enforce namespaces
It seems to me that the type keyword should permanently enforce that a RdrName lives in a particular namespace. Currently it only acts as a syntactic marker so that type constructors which looks like variables can be included in export lists.
The following example is accepted by GHC. As `A` is parsed as a type constructor but later put into the data constructor namespace.
```hs
{-# LANGUAGE ExplicitNamespaces #-}
{-# LANGUAGE TypeFamilies #-}
module M ( T (type A) ) where
data T = A
class Foo a where
type A a
foo :: a -> Int
```
The fix is to track uses of ExplicitNamespaces in the AST and then use this information in the renamer.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Explicit namespaces doesn't enforce namespaces","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.0.1","keywords":["newcomer"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"It seems to me that the type keyword should permanently enforce that a RdrName lives in a particular namespace. Currently it only acts as a syntactic marker so that type constructors which looks like variables can be included in export lists. \r\n\r\nThe following example is accepted by GHC. As `A` is parsed as a type constructor but later put into the data constructor namespace. \r\n\r\n{{{#!hs\r\n{-# LANGUAGE ExplicitNamespaces #-}\r\n{-# LANGUAGE TypeFamilies #-}\r\nmodule M ( T (type A) ) where\r\n\r\ndata T = A\r\n\r\nclass Foo a where\r\n type A a\r\n foo :: a -> Int\r\n}}}\r\n\r\nThe fix is to track uses of ExplicitNamespaces in the AST and then use this information in the renamer. ","type_of_failure":"OtherFailure","blocking":[]} -->
issue