@@ -288,42 +288,43 @@ fromTypeVariableScheme scheme =
290-- FROM MANY NAMES
290-- FROM MANY NAMES
292+-- Creating a unique name by combining all the subnames can create names
293+-- longer than 256 bytes relatively easily. So instead, the first given name
294+-- (e.g. foo) is prefixed chars that are valid in JS but not Elm (e.g. _M$foo)
296+-- This should be a unique name since 0.19 disallows shadowing. It would not
297+-- be possible for multiple top-level cycles to include values with the same
298+-- name, so the important thing is to make the cycle name distinct from the
299+-- normal name. Same logic for destructuring patterns like (x,y)
293fromManyNames :: [Name] -> Name
302fromManyNames :: [Name] -> Name
294fromManyNames names =
303fromManyNames names =
296− !(I# size#) = sum (map (\(Utf8.Utf8 ba#) -> I# (sizeofByteArray# ba# +# 1#)) names)
301− case newByteArray# size# s of
303− case writeNames mba# 0# names s of
305− case unsafeFreezeByteArray# mba# s of
306− (# s, ba# #) -> (# s, Utf8.Utf8 ba# #)
310−writeNames :: MutableByteArray# s -> Int# -> [Name] -> State# s -> State# s
311−writeNames mba# !offset# names s =
312 case names of
304 case names of
314− s
306+ error "trying to use fromManyNames on an empty list"
316− (Utf8.Utf8 ba#) : names ->
308+ Utf8.Utf8 ba# : _ ->
317− case writeWord8Array# mba# offset# 0x24## {- $ -} s of
320− !offset1# = offset# +# 1#
321− !len# = sizeofByteArray# ba#
310+ len# = sizeofByteArray# ba#
322− !newOffset# = offset1# +# len#
324− case copyByteArray# ba# 0# mba# offset1# len# s of
312+ runST
315+ case newByteArray# (len# +# 3#) s of
325− s ->
316+ (# s, mba# #) ->
326− writeNames mba# newOffset# names s
317+ case writeWord8Array# mba# 0# 0x5F## {-_-} s of
319+ case writeWord8Array# mba# 1# 0x4D## {-M-} s of
321+ case writeWord8Array# mba# 2# 0x24## {-$-} s of
323+ case copyByteArray# ba# 0# mba# 3# len# s of
325+ case unsafeFreezeByteArray# mba# s of
326+ (# s, ba# #) -> (# s, Utf8.Utf8 ba# #)