[Git][ghc/ghc][master] JS: Fix missing local variable declarations

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Aug 7 10:28:14 UTC 2023



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


Commits:
b938950d by Luite Stegeman at 2023-08-07T06:27:51-04:00
JS: Fix missing local variable declarations

This fixes some missing local variable declarations that were
found by running the testsuite in strict mode.

Fixes #23775

- - - - -


7 changed files:

- compiler/GHC/JS/Make.hs
- compiler/GHC/StgToJS/Expr.hs
- rts/js/arith.js
- rts/js/environment.js
- rts/js/thread.js
- testsuite/tests/javascript/js-callback03.hs
- testsuite/tests/programs/seward-space-leak/test.T


Changes:

=====================================
compiler/GHC/JS/Make.hs
=====================================
@@ -268,7 +268,7 @@ jVar f = UnsatBlock . IS $ do
            (block, is) <- runIdentSupply $ toSat_ f []
            let addDecls (BlockStat ss) =
                   BlockStat $ map decl is ++ ss
-               addDecls x = x
+               addDecls x = BlockStat (map decl is ++ [x])
            return $ addDecls block
 
 jFunction :: Ident -> [Ident] -> JStat -> JStat


=====================================
compiler/GHC/StgToJS/Expr.hs
=====================================
@@ -509,7 +509,7 @@ optimizeFree offset ids = do
 allocCls :: Maybe JStat -> [(Id, CgStgRhs)] -> G JStat
 allocCls dynMiddle xs = do
    (stat, dyn) <- partitionEithers <$> mapM toCl xs
-   ac <- allocDynAll True dynMiddle dyn
+   ac <- allocDynAll False dynMiddle dyn
    pure (mconcat stat <> ac)
   where
     -- left = static, right = dynamic


=====================================
rts/js/arith.js
=====================================
@@ -394,9 +394,9 @@ function h$decodeFloatInt(d) {
             h$convertFloat[0] = d*8388608; // put d in the normal range (~ shift left 23 bits)
             i = h$convertInt[0];
             s = (i&8388607) | 8388608;
-            e = ((i >> 23) & 0xff) - 173; // take into account normalization above (150+23)
-            TRACE_ARITH("decodeFloatInt s: " + (sgn * s) +  " e: " + e)
-            RETURN_UBX_TUP2(sgn*s, e)
+            exp = ((i >> 23) & 0xff) - 173; // take into account normalization above (150+23)
+            TRACE_ARITH("decodeFloatInt s: " + (sgn * s) +  " e: " + exp)
+            RETURN_UBX_TUP2(sgn*s, exp)
         }
     } else {
       TRACE_ARITH("decodeFloatInt s: " + (sgn * (s|8388608)) +  " e: " + (exp-150))


=====================================
rts/js/environment.js
=====================================
@@ -166,7 +166,7 @@ function h$getProgArgv(argc_v,argc_off,argv_v,argv_off) {
 }
 
 function h$setProgArgv(n, ptr_d, ptr_o) {
-  args = [];
+  var args = [];
   for(var i=0;i<n;i++) {
     var off = ptr_o+4*i;
     GET_ADDR(ptr_d,off,p,o);


=====================================
rts/js/thread.js
=====================================
@@ -138,6 +138,7 @@ function h$getThreadLabel(t) {
 
 function h$listThreads() {
   var r = h$newArray(0,null);
+  var t;
 
   if (h$currentThread) r.push(h$currentThread);
 


=====================================
testsuite/tests/javascript/js-callback03.hs
=====================================
@@ -10,7 +10,7 @@ foreign import javascript "((x) => { globalF(x); })"
 foreign import javascript "((x,y) => { return x + y })"
   js_plus :: JSVal -> JSVal -> IO JSVal
 
-foreign import javascript "((g) => { globalG = g; })"
+foreign import javascript "((g) => { globalThis.globalG = g; })"
   setG :: Callback (JSVal -> JSVal -> IO JSVal) -> IO ()
 
 foreign import javascript "((x,y) => { return globalG(x,y); })"


=====================================
testsuite/tests/programs/seward-space-leak/test.T
=====================================
@@ -1,5 +1,4 @@
 test('seward-space-leak', [extra_files(['Main.lhs'])
                           , when(fast(), skip)
-                          , js_broken(22352)
                           ], multimod_compile_and_run,
      ['Main', ''])



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b938950d98945f437f1e28b15a0a3629bfe336c2
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/20230807/4f501d7b/attachment-0001.html>


More information about the ghc-commits mailing list