(Previously discussed at https://gitlab.haskell.org/ghc/ghc/-/issues/21468)
At the moment Data.Char.chr is implemented as follows:
chr :: Int -> Char
chr i@(I# i#)
| isTrue# (int2Word# i# `leWord#` 0x10FFFF##) = C# (chr# i#)
| otherwise
= errorWithoutStackTrace ("Prelude.chr: bad argument: " ++ showSignedInt (I# 9#) i "")
The error message is terrible: chr actually is not exported from Prelude and it would be nice to explain why exactly the argument is bad (that's because it is outside of Unicode range). I propose to change it to:
| otherwise
= error ("Argument of Data.Char.chr is outside of the Unicode range 0..0x10FFFF: " ++ showSignedInt (I# 9#) i "")
This also switches errorWithoutStackTrace to error: even while there is no HasCallStack, let's at least not suppress a call stack.
(Previously discussed at https://gitlab.haskell.org/ghc/ghc/-/issues/21468)
At the moment
Data.Char.chris implemented as follows:The error message is terrible:
chractually is not exported fromPreludeand it would be nice to explain why exactly the argument is bad (that's because it is outside of Unicode range). I propose to change it to:This also switches
errorWithoutStackTracetoerror: even while there is noHasCallStack, let's at least not suppress a call stack.