ghcjs / jsaddle

JavaScript interface that works with GHCJS or GHC
116 stars 62 forks source link

Text function and emojis causes jsaddle errors in certain cases #144

Open alexfmpe opened 4 months ago

alexfmpe commented 4 months ago

Porting from https://github.com/obsidiansystems/obelisk/issues/1055. Happens with

Works: text "👋 Contact Support"

and

text "👋"

Causes JSaddle Error:

text "👋" >> text "Contact Support"

JSaddle Error:

jsaddle Results decode failed : "{"tag":"BatchResults","contents":[215,{"tag":"Success","contents":[[],[{"tag":"ValueToStringResult","contents":"\udc4bContact Support"}]]}]}"
CallStack (from HasCallStack):
error, called at src/Language/Javascript/JSaddle/WebSockets.hs:103:50 in jsaddle-warp-0.9.8.2-DFAPM2CvatBGFm3L9xaA1B:Language.Javascript.JSaddle.WebSockets
hsyl20 commented 4 months ago

👋 is encoded as:

So here it looks like we encode it to UTF-16 and then drop the first code unit (d83d). So in the end result instead of having "\u1f44bContact Support" we get "\udc4bContact Support".

Could you dump rule's rewrites with GHC's -ddump-rule-rewrites to see if a fusion rule in Data.JSString.Internal.Fusion fire?