Optimiser: Correctly deal with strings starting with unicode characters in exprConApp_maybe
For example: "\0" is encoded to "C0 80", then the rule would correct use a decoding function to work out the first character was "C0 80" but then just used BS.tail so the rest of the string was "80". This resulted in "\0" being transformed into '\C0\80' : unpackCStringUTF8# "80" Which is obviously bogus. I rewrote the function to call utf8UnconsByteString directly and avoid the roundtrip through Faststring so now the head/tail is computed by the same call. Fixes #19976
Showing
- compiler/GHC/Core/SimpleOpt.hs 17 additions, 21 deletionscompiler/GHC/Core/SimpleOpt.hs
- libraries/ghc-boot/GHC/Utils/Encoding.hs 9 additions, 0 deletionslibraries/ghc-boot/GHC/Utils/Encoding.hs
- testsuite/tests/simplCore/should_compile/T9400.hs 4 additions, 0 deletionstestsuite/tests/simplCore/should_compile/T9400.hs
- testsuite/tests/simplCore/should_compile/T9400.stderr 20 additions, 6 deletionstestsuite/tests/simplCore/should_compile/T9400.stderr
Loading
Please register or sign in to comment