summaryrefslogtreecommitdiff
path: root/testsuite/tests/simplCore
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-06-11 10:48:25 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-23 02:58:35 -0400
commit7f6454fb8cd92b2b2ad4e88fa6d81e34d43edb9a (patch)
tree22dbe8c64e1761856913450fa297e2797c905fa2 /testsuite/tests/simplCore
parent87f57ecf2523e83d8dd9cad919a6f2010f630ad0 (diff)
downloadhaskell-7f6454fb8cd92b2b2ad4e88fa6d81e34d43edb9a.tar.gz
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
Diffstat (limited to 'testsuite/tests/simplCore')
-rw-r--r--testsuite/tests/simplCore/should_compile/T9400.hs4
-rw-r--r--testsuite/tests/simplCore/should_compile/T9400.stderr26
2 files changed, 24 insertions, 6 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T9400.hs b/testsuite/tests/simplCore/should_compile/T9400.hs
index 4e9cb72cb9..85aad51564 100644
--- a/testsuite/tests/simplCore/should_compile/T9400.hs
+++ b/testsuite/tests/simplCore/should_compile/T9400.hs
@@ -16,3 +16,7 @@ main = do
(x:xs) -> putStrLn xs
case "ab" of
"" -> putStrLn "fail"
+ case "\0abc" of
+ (x:xs) -> putStrLn xs
+ case "zażółćz" of
+ (x:xs) -> putStrLn xs
diff --git a/testsuite/tests/simplCore/should_compile/T9400.stderr b/testsuite/tests/simplCore/should_compile/T9400.stderr
index c4584f460e..511a481d96 100644
--- a/testsuite/tests/simplCore/should_compile/T9400.stderr
+++ b/testsuite/tests/simplCore/should_compile/T9400.stderr
@@ -9,7 +9,7 @@ T9400.hs:18:9: warning: [-Woverlapping-patterns (in -Wdefault)]
==================== Tidy Core ====================
Result size of Tidy Core
- = {terms: 38, types: 22, coercions: 0, joins: 0/0}
+ = {terms: 48, types: 28, coercions: 0, joins: 0/0}
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
$trModule1 :: Addr#
@@ -36,7 +36,7 @@ T9400.$trModule :: Module
[GblId, Unf=OtherCon []]
T9400.$trModule = GHC.Types.Module $trModule2 $trModule4
--- RHS size: {terms: 23, types: 15, coercions: 0, joins: 0/0}
+-- RHS size: {terms: 33, types: 21, coercions: 0, joins: 0/0}
main :: IO ()
[GblId]
main
@@ -64,10 +64,24 @@ main
@()
@()
(putStrLn (unpackCString# "efg"#))
- (case Control.Exception.Base.patError
- @LiftedRep @() "T9400.hs:(17,5)-(18,29)|case"#
- of wild {
- }))))
+ (>>
+ @IO
+ GHC.Base.$fMonadIO
+ @()
+ @()
+ (case Control.Exception.Base.patError
+ @LiftedRep @() "T9400.hs:(17,5)-(18,29)|case"#
+ of wild {
+ })
+ (>>
+ @IO
+ GHC.Base.$fMonadIO
+ @()
+ @()
+ (putStrLn (unpackCStringUtf8# "abc"#))
+ (putStrLn
+ (unpackCStringUtf8#
+ "a\\197\\188\\195\\179\\197\\130\\196\\135z"#)))))))