Admin message

Due to a large amount of spam we do not allow new users to create repositories, they are "external" users. If you are a new user and want to create a repository, for example for forking GHC, open a new issue on ghc/ghc using the "get-verified" issue template

Bogus logic around TcRnExportHiddenComponents
Consider this function in `compiler/GHC/Tc/Gen/Export.hs`: ```haskell lookup_ie_kids_all :: IE GhcPs -> LIEWrappedName GhcPs -> GlobalRdrElt -> RnM [GlobalRdrElt] lookup_ie_kids_all ie (L _loc rdr) gre = do { let name = greName gre gres = findChildren kids_env name -- We only choose level 0 exports when filling in part of an export list implicitly. ; let kids_0 = mapMaybe pickLevelZeroGRE gres ; addUsedKids (ieWrappedName rdr) kids_0 ; when (null kids_0) $ if isTyConName name then addTcRnDiagnostic (TcRnDodgyExports gre) else -- This occurs when you export T(..), but -- only import T abstractly, or T is a synonym. addErr (TcRnExportHiddenComponents ie) ; return kids_0 } ``` And more specifically, this part of it: ```haskell when (null kids_0) $ if isTyConName name then addTcRnDiagnostic (TcRnDodgyExports gre) else -- This occurs when you export T(..), but -- only import T abstractly, or T is a synonym. addErr (TcRnExportHiddenComponents ie) ``` 1. First of all, `TcRnExportHiddenComponents` is untested. Initially I could not figure out how to trigger it. 2. Secondly, the placement of the comment seems to suggest that only the `else` branch handles the case where `T(..)` has no children, when in reality it is handled by the `then` code path (e.g. in test case `DodgyExports01`). 3. Thirdly, what's the rationale behind the `isTyConName` check? If `T(..)` is to have any children, of course it's a `TcClsName`. The other options are: * `TvName` – never in the global env, unreachable case * `VarName` or `FldName` – would be rejected with `PsErrVarForTyCon` (test case `mod89`), unreachable case * `DataName` – could only occur with an explicit namespace specifier ```haskell {-# LANGUAGE ExplicitNamespaces #-} module M (data MkR(..)) where data R = MkR { fld :: Int } ``` So, as far as I can tell, the only way to produce `TcRnExportHiddenComponents` is to try to use a wildcard subordinate export with a data constructor or pattern synonym, leading to this error message: ``` M.hs:2:13: error: [GHC-94558] The export item ‘data MkR(..)’ attempts to export constructors or class methods that are not visible here | 2 | module M (data MkR(..)) where | ^^^^^^^^^^^^ ``` which makes no sense whatsoever, because you wouldn't report "no **visible** children" for something that can never have children to begin with. Also it's an error for some reason, whereas all other cases are `-Wdodgy-exports` warning. I suggest to drop this special case, removing `TcRnExportHiddenComponents` entirely: ```haskell when (null kids_0) $ addTcRnDiagnostic (TcRnDodgyExports gre) ``` By using `TcRnDodgyExports` unconditionally, we get this diagnostic, which in my opinion is an improvement: ``` M.hs:2:13: warning: [GHC-75356] [-Wdodgy-exports (in -Wextra)] The export item ‘MkR(..)’ suggests that ‘MkR’ has children, but it is not a type constructor or a class ```
issue