[Git][ghc/ghc][master] Don't emit unprintable characters when printing Uniques

Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 3b3a5dec by Ben Gamari at 2025-05-15T16:10:01-04:00 Don't emit unprintable characters when printing Uniques When faced with an unprintable tag we now instead print the codepoint number. Fixes #25989. (cherry picked from commit e832b1fadee66e8d6dd7b019368974756f8f8c46) - - - - - 1 changed file: - compiler/GHC/Types/Unique.hs Changes: ===================================== compiler/GHC/Types/Unique.hs ===================================== @@ -302,8 +302,14 @@ instance Uniquable Unique where showUnique :: Unique -> String showUnique uniq - = case unpkUnique uniq of - (tag, u) -> tag : w64ToBase62 u + = tagStr ++ w64ToBase62 u + where + (tag, u) = unpkUnique uniq + -- Avoid emitting non-printable characters in pretty uniques. + -- See #25989. + tagStr + | tag < 'A' || tag > 'z' = show (ord tag) ++ "_" + | otherwise = [tag] pprUniqueAlways :: IsLine doc => Unique -> doc -- The "always" means regardless of -dsuppress-uniques View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b3a5decd11e7daffb758bd2f02aaed2... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3b3a5decd11e7daffb758bd2f02aaed2... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)