[Git][ghc/ghc][wip/int-index/imp-exp-wildcards] Subordinate namespace-specified wildcards
Vladislav Zavialov pushed to branch wip/int-index/imp-exp-wildcards at Glasgow Haskell Compiler / GHC Commits: 7acd26bd by Vladislav Zavialov at 2025-12-09T01:48:18+01:00 Subordinate namespace-specified wildcards Add support for subordinate namespace-specified wildcards `X(type ..)` and `X(data ..)` to import and export lists. Examples: import M (Cls(type ..)) -- imports Cls and all its associated types import M (Cls(data ..)) -- imports Cls and all its methods module M (R(data ..), C(type ..)) where -- exports R and all its data constructors and record fields; -- exports C and all its associated types, but not its methods The scope of this change is limited to the case where the wildcard is the only subordinate import/export item, whereas the more complex forms `X(type .., f)` or `X(type .., data ..)` are unsupported and raise the newly introduced PsErrUnsupportedExplicitNamespace error. This restriction may be lifted later. Summary of the changes: 1. Refactor IEThingAll to store its extension field XIEThingAll as a record IEThingAllExt instead of a tuple. 2. Extend the AST by adding a NamespaceSpecifier field to IEThingAllExt, representing an optional namespace specifier `type` or `data` in front of a subordinate wildcard `X(..)`. 3. Extend the grammar in Parser.y with productions for `type ..` and `data ..` in subordinate import/export items. 4. Introduce `filterByNamespaceGREs` to filter [GlobalRdrElt] by a NamespaceSpecifier; use it in `filterImports` and `exports_from_avail` to account for the namespace specifier in IEThingAll. 5. Improve diagnostics by storing more information in DodgyImportsEmptyParent and DodgyExportsEmptyParent. Test cases: T25901_sub_e T25901_sub_f T25901_sub_g T25901_sub_a T25901_sub_b T25901_sub_c T25901_sub_d T25901_sub_w DodgyImports02 DodgyImports03 DodgyImports04 - - - - - 46 changed files: - compiler/GHC/Hs/ImpExp.hs - compiler/GHC/Hs/Instances.hs - compiler/GHC/Parser.y - compiler/GHC/Parser/Errors/Ppr.hs - compiler/GHC/Parser/Errors/Types.hs - compiler/GHC/Parser/PostProcess.hs - compiler/GHC/Rename/Names.hs - compiler/GHC/Tc/Errors/Ppr.hs - compiler/GHC/Tc/Errors/Types.hs - compiler/GHC/Tc/Gen/Export.hs - compiler/GHC/Types/Error/Codes.hs - compiler/GHC/Types/Name/Reader.hs - testsuite/tests/haddock/should_compile_flag_haddock/T17544_kw.stderr - + testsuite/tests/rename/should_compile/T25901_sub_e.hs - + testsuite/tests/rename/should_compile/T25901_sub_f.hs - + testsuite/tests/rename/should_compile/T25901_sub_f.stderr - + testsuite/tests/rename/should_compile/T25901_sub_g.hs - + testsuite/tests/rename/should_compile/T25901_sub_g.stderr - + testsuite/tests/rename/should_compile/T25901_sub_g_helper.hs - testsuite/tests/rename/should_compile/all.T - testsuite/tests/rename/should_fail/T23570b.stderr - + testsuite/tests/rename/should_fail/T25901_sub_a.hs - + testsuite/tests/rename/should_fail/T25901_sub_a.stderr - + testsuite/tests/rename/should_fail/T25901_sub_b.hs - + testsuite/tests/rename/should_fail/T25901_sub_b.stderr - + testsuite/tests/rename/should_fail/T25901_sub_c.hs - + testsuite/tests/rename/should_fail/T25901_sub_c.stderr - + testsuite/tests/rename/should_fail/T25901_sub_c_helper.hs - + testsuite/tests/rename/should_fail/T25901_sub_d.hs - + testsuite/tests/rename/should_fail/T25901_sub_d.stderr - + testsuite/tests/rename/should_fail/T25901_sub_d_helper.hs - + testsuite/tests/rename/should_fail/T25901_sub_w.hs - + testsuite/tests/rename/should_fail/T25901_sub_w.stderr - testsuite/tests/rename/should_fail/all.T - testsuite/tests/warnings/should_compile/DodgyExports03.stderr - testsuite/tests/warnings/should_compile/DodgyImports.stderr - + testsuite/tests/warnings/should_compile/DodgyImports02.hs - + testsuite/tests/warnings/should_compile/DodgyImports02.stderr - + testsuite/tests/warnings/should_compile/DodgyImports03.hs - + testsuite/tests/warnings/should_compile/DodgyImports03.stderr - + testsuite/tests/warnings/should_compile/DodgyImports03_helper.hs - + testsuite/tests/warnings/should_compile/DodgyImports04.hs - + testsuite/tests/warnings/should_compile/DodgyImports04.stderr - testsuite/tests/warnings/should_compile/DodgyImports_hiding.stderr - testsuite/tests/warnings/should_compile/all.T - utils/check-exact/ExactPrint.hs The diff was not included because it is too large. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7acd26bd317252d3270d08e1ec0d240a... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7acd26bd317252d3270d08e1ec0d240a... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Vladislav Zavialov (@int-index)