
Vladislav Zavialov pushed to branch wip/int-index/enforce-namespaces at Glasgow Haskell Compiler / GHC Commits: 97ed302a by Vladislav Zavialov at 2025-05-08T02:28:13+03:00 refactor: mkSubordinateError - - - - - 1 changed file: - compiler/GHC/Rename/Names.hs Changes: ===================================== compiler/GHC/Rename/Names.hs ===================================== @@ -1382,16 +1382,7 @@ filterImports hsc_env iface decl_spec (Just (want_hiding, L l import_items)) -- to find 'b' and 'd'. So we make up an import item -- to report as failing, namely T( b, d ). -- c.f. #15413 - subordinate_err = - assertPpr (length unavailable + length nontype == length items) - (ppr items) $ - IsSubordinateError { subordinate_err_parent = gre - , subordinate_err_unavailable = unavailable - , subordinate_err_nontype = nontype } - unavailable = - [ (occNameFS . rdrNameOcc . ieWrappedName) wname - | LookupChildNotFound (L _ wname) <- children_errs ] - nontype = [ g | LookupChildNonType{lce_nontype_item = g} <- children_errs ] + subordinate_err = mkSubordinateError gre children_errs in bad_import_w ie subordinate_err let name' = replaceWrappedName rdr_tc name @@ -1447,6 +1438,22 @@ data IsSubordinateError , subordinate_err_nontype :: [GlobalRdrElt] } | IsNotSubordinate +mkSubordinateError :: GlobalRdrElt -> [LookupChildError] -> IsSubordinateError +mkSubordinateError gre children_errs = foldr add init_acc children_errs + where + init_acc :: IsSubordinateError + init_acc = IsSubordinateError gre [] [] + + add :: LookupChildError -> IsSubordinateError -> IsSubordinateError + add children_err sub@IsSubordinateError{} = + case children_err of + LookupChildNonType{lce_nontype_item = g} -> + sub { subordinate_err_nontype = g : subordinate_err_nontype sub } + LookupChildNotFound (L _ wname) -> + let fs = (occNameFS . rdrNameOcc . ieWrappedName) wname + in sub { subordinate_err_unavailable = fs : subordinate_err_unavailable sub } + add _ IsNotSubordinate = panic "mkSubordinateError: IsNotSubordinate" + data IELookupError = QualImportError RdrName | BadImport (IE GhcPs) IsSubordinateError View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97ed302a40d8362975c7703d4e402bf0... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/97ed302a40d8362975c7703d4e402bf0... You're receiving this email because of your account on gitlab.haskell.org.