[Git][ghc/ghc][master] JS: remove broken newIdents from JStg Monad

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Nov 7 07:22:35 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
dd88a260 by Luite Stegeman at 2023-11-07T02:21:53-05:00
JS: remove broken newIdents from JStg Monad

GHC.JS.JStg.Monad.newIdents was broken, resulting in duplicate
identifiers being generated in h$c1, h$c2, ... .

This change removes the broken newIdents.

- - - - -


2 changed files:

- compiler/GHC/JS/JStg/Monad.hs
- compiler/GHC/JS/Make.hs


Changes:

=====================================
compiler/GHC/JS/JStg/Monad.hs
=====================================
@@ -40,7 +40,6 @@ module GHC.JS.JStg.Monad
   , JSM
   , withTag
   , newIdent
-  , newIdents
   , initJSM
   ) where
 
@@ -95,19 +94,6 @@ newIdent = do env <- get
 mk_ident :: FastString -> Unique -> Ident
 mk_ident t i = global (mconcat [t, "_", mkFastString (show i)])
 
-
-
--- | A special case optimization over @newIdent at . Given a number of @Ident@ to
--- generate, generate all of them at one time and update the state once rather
--- than n times.
-newIdents :: Int -> JSM [Ident]
-newIdents 0 = return []
-newIdents n = do env <- get
-                 let is  = take n (uniqsFromSupply $ ids env)
-                     tag = prefix env
-                 return $ fmap (mk_ident tag) is
-
-
 -- | Set the tag for @Ident at s for all remaining computations.
 tag_names :: FastString -> JSM ()
 tag_names tag = modify' (\env -> env {prefix = tag})


=====================================
compiler/GHC/JS/Make.hs
=====================================
@@ -149,6 +149,7 @@ import GHC.JS.JStg.Monad
 import GHC.JS.Transform
 
 import Control.Arrow ((***))
+import Control.Monad (replicateM)
 import Data.Tuple
 
 import qualified Data.Map as M
@@ -325,7 +326,7 @@ jFunctionSized
   -> ([JStgExpr] -> JSM JStgStat) -- ^ function body, input is locally unique generated variables
   -> JSM JStgStat
 jFunctionSized name arity body = do
-  func_args <- newIdents arity
+  func_args <- replicateM arity newIdent
   FuncStat name func_args <$> (body $ toJExpr <$> func_args)
 
 -- | Construct a top-level function subject to JS hoisting. Special case where



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/dd88a26052bdef0dd4c00e1a4781ec3ef532c5db
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/20231107/5cf57db7/attachment-0001.html>


More information about the ghc-commits mailing list