[Git][ghc/ghc][master] JS: fix JS stack printing (#23565)

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Jun 29 01:12:21 UTC 2023



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


Commits:
78b2f3cc by Sylvain Henry at 2023-06-28T21:12:02-04:00
JS: fix JS stack printing (#23565)

- - - - -


3 changed files:

- rts/js/string.js
- + testsuite/tests/javascript/T23565.hs
- testsuite/tests/javascript/all.T


Changes:

=====================================
rts/js/string.js
=====================================
@@ -739,7 +739,7 @@ function h$throwJSException(e) {
   if(typeof e === 'string') {
     strVal = e;
   } else if(e instanceof Error) {
-    strVal = e.toString() + '\n' + Array.prototype.join.call(e.stack, '\n');
+    strVal = e.toString() + '\n' + e.stack;
   } else {
     strVal = "" + e;
   }


=====================================
testsuite/tests/javascript/T23565.hs
=====================================
@@ -0,0 +1,17 @@
+module Main where
+
+import GHC.JS.Prim
+import Control.Exception
+import System.Exit
+
+main :: IO ()
+main = foo `catch` \(JSException val s) -> do
+  -- check that the message (including call stack) hasn't too many lines
+  -- (#23565)
+  if length (lines s) >= 10
+    then putStrLn "Failure: too many lines" >> exitFailure
+    else pure ()
+
+
+foreign import javascript "foo"
+  foo :: IO ()


=====================================
testsuite/tests/javascript/all.T
=====================================
@@ -18,3 +18,4 @@ test('js-callback05', js_skip, compile_and_run, [''])
 
 test('T23346', normal, compile_and_run, [''])
 test('T22455', normal, compile_and_run, ['-ddisable-js-minifier'])
+test('T23565', normal, compile_and_run, [''])



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/78b2f3ccb1d7603e11b3f364646240e361512cbc
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/20230628/6ad50974/attachment-0001.html>


More information about the ghc-commits mailing list