[Git][ghc/ghc][wip/js-staging] Codegen: fix codegen of string literals

Sylvain Henry (@hsyl20) gitlab at gitlab.haskell.org
Mon Aug 29 16:38:09 UTC 2022



Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC


Commits:
0f02642e by Sylvain Henry at 2022-08-29T18:39:23+02:00
Codegen: fix codegen of string literals

Due to FastString change:
 Before: Text.pack . BSC.unpack
 After:  mkFastString . BSC.unpack

It seems that Text handles buggy multi-byte codepoints split into
several String Chars.

- - - - -


1 changed file:

- compiler/GHC/StgToJS/Linker/Compactor.hs


Changes:

=====================================
compiler/GHC/StgToJS/Linker/Compactor.hs
=====================================
@@ -400,8 +400,9 @@ staticDeclStat (StaticInfo si sv _) =
       ssu StaticUnboxedStringOffset {} = 0
   in  maybe (appS "h$di" [toJExpr si']) (\v -> DeclStat si' `mappend` (toJExpr si' |= v)) (ssv sv)
 
+-- | JS expression corresponding to a static string
 initStr :: BS.ByteString -> JExpr
-initStr str = app "h$str" [ValExpr (JStr . mkFastString . BSC.unpack $! str)]
+initStr str = app "h$str" [ValExpr (JStr . mkFastStringByteString $! str)]
 
 -- | rename a heap object, which means adding it to the
 --  static init table in addition to the renamer



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f02642ef60dd3fb07d80a49a3b826b7bf0de7ea

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0f02642ef60dd3fb07d80a49a3b826b7bf0de7ea
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20220829/8c3a22fb/attachment-0001.html>


More information about the ghc-commits mailing list