Admin message

Due to a large amount of spam we do not allow new users to create repositories, they are "external" users. If you are a new user and want to create a repository, for example for forking GHC, open a new issue on ghc/ghc using the "get-verified" issue template

JavaScript Backend: Compiler panic when compiling T26537
## Summary The JavaScript backend fails to compile T26537 (added by !15042 to test #26537) if the compiler is built with `-DDEBUG`. ## Steps to reproduce Compile `T26537.hs` using a GHC built with `-DDEBUG` (I have modified the `panic` function to attach the call stack.): ``` $ javascript-unknown-ghcjs-ghc -fforce-recomp -O2 T26537.hs [1 of 2] Compiling Main ( T26537.hs, T26537.o ) <no location info>: error: panic! (the 'impossible' happened) GHC version 9.15.20251108: zipWithEqual: unequal lists CallStack (from HasCallStack): panic, called at compiler/GHC/Utils/Misc.hs:262:32 in ghc-9.15-inplace:GHC.Utils.Misc zipWithEqual, called at compiler/GHC/Utils/Misc.hs:260:40 in ghc-9.15-inplace:GHC.Utils.Misc ... zipWithEqual, called at compiler/GHC/Utils/Misc.hs:260:40 in ghc-9.15-inplace:GHC.Utils.Misc zipWithEqual, called at compiler/GHC/JS/Make.hs:602:33 in ghc-9.15-inplace:GHC.JS.Make assignAllEqual, called at compiler/GHC/StgToJS/Utils.hs:91:3 in ghc-9.15-inplace:GHC.StgToJS.Utils Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug ``` A smaller program reproduces the panic: ```haskell {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} import GHC.Exts type D8 = (# Double#, Double#, Double#, Double#, Double#, Double#, Double#, Double# #) type D64 = (# D8, D8, D8, D8, D8, D8, D8, D8 #) type D128 = (# D64, D64 #) unD# :: Double -> Double# unD# (D# x) = x mkD8 :: Double -> D8 mkD8 x = (# unD# x, unD# (x + 1), unD# (x + 2), unD# (x + 3), unD# (x + 4), unD# (x + 5), unD# (x + 6), unD# (x + 7) #) {-# NOINLINE mkD8 #-} mkD64 :: Double -> D64 mkD64 x = (# mkD8 x, mkD8 (x + 8), mkD8 (x + 16), mkD8 (x + 24), mkD8 (x + 32), mkD8 (x + 40), mkD8 (x + 48), mkD8 (x + 56) #) {-# NOINLINE mkD64 #-} mkD128 :: Double -> D128 mkD128 x = (# mkD64 x, mkD64 (x + 64) #) {-# NOINLINE mkD128 #-} addD8 :: D8 -> D8 -> D8 addD8 (# x0, x1, x2, x3, x4, x5, x6, x7 #) (# y0, y1, y2, y3, y4, y5, y6, y7 #) = (# x0 +## y0, x1 +## y1, x2 +## y2, x3 +## y3, x4 +## y4, x5 +## y5, x6 +## y6, x7 +## y7 #) {-# NOINLINE addD8 #-} addD64 :: D64 -> D64 -> D64 addD64 (# x0, x1, x2, x3, x4, x5, x6, x7 #) (# y0, y1, y2, y3, y4, y5, y6, y7 #) = (# addD8 x0 y0, addD8 x1 y1, addD8 x2 y2, addD8 x3 y3, addD8 x4 y4, addD8 x5 y5, addD8 x6 y6, addD8 x7 y7 #) {-# NOINLINE addD64 #-} addD128 :: D128 -> D128 -> D128 addD128 (# x0, x1 #) (# y0, y1 #) = (# addD64 x0 y0, addD64 x1 y1 #) {-# NOINLINE addD128 #-} toListD8 :: D8 -> [Double] toListD8 (# x0, x1, x2, x3, x4, x5, x6, x7 #) = [D# x0, D# x1, D# x2, D# x3, D# x4, D# x5, D# x6, D# x7] {-# NOINLINE toListD8 #-} toListD64 :: D64 -> [Double] toListD64 (# x0, x1, x2, x3, x4, x5, x6, x7 #) = concat [toListD8 x0, toListD8 x1, toListD8 x2, toListD8 x3, toListD8 x4, toListD8 x5, toListD8 x6, toListD8 x7] {-# NOINLINE toListD64 #-} toListD128 :: D128 -> [Double] toListD128 (# x0, x1 #) = concat [toListD64 x0, toListD64 x1] {-# NOINLINE toListD128 #-} data T = MkT D128 D8 mkT :: Double -> T mkT x = MkT (mkD128 x) (mkD8 (x + 128)) {-# NOINLINE mkT #-} addT :: T -> T -> T addT (MkT x0 x1) (MkT y0 y1) = MkT (addD128 x0 y0) (addD8 x1 y1) {-# NOINLINE addT #-} toListT :: T -> [Double] toListT (MkT x0 x1) = toListD128 x0 ++ toListD8 x1 {-# NOINLINE toListT #-} main :: IO () main = do let n = 128 + 8 let !x = mkT 0 !y = mkT n print $ toListT x print $ toListT y print $ toListT (addT x y) print $ toListT x == [0..n-1] print $ toListT y == [n..2*n-1] print $ toListT (addT x y) == zipWith (+) [0..n-1] [n..2*n-1] ``` ``` $ javascript-unknown-ghcjs-ghc -fforce-recomp -O2 T26537_medium.hs [1 of 2] Compiling Main ( T26537_medium.hs, T26537_medium.o ) <no location info>: error: panic! (the 'impossible' happened) GHC version 9.15.20251108: zipWithEqual: unequal lists CallStack (from HasCallStack): panic, called at compiler/GHC/Utils/Misc.hs:262:32 in ghc-9.15-inplace:GHC.Utils.Misc ... ``` If I shrink the program more, the compiler does not panic but the generated program fails with a ReferenceError: ```haskell {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} import GHC.Exts type D8 = (# Double#, Double#, Double#, Double#, Double#, Double#, Double#, Double# #) type D64 = (# D8, D8, D8, D8, D8, D8, D8, D8 #) unD# :: Double -> Double# unD# (D# x) = x mkD8 :: Double -> D8 mkD8 x = (# unD# x, unD# (x + 1), unD# (x + 2), unD# (x + 3), unD# (x + 4), unD# (x + 5), unD# (x + 6), unD# (x + 7) #) {-# NOINLINE mkD8 #-} mkD64 :: Double -> D64 mkD64 x = (# mkD8 x, mkD8 (x + 8), mkD8 (x + 16), mkD8 (x + 24), mkD8 (x + 32), mkD8 (x + 40), mkD8 (x + 48), mkD8 (x + 56) #) {-# NOINLINE mkD64 #-} addD8 :: D8 -> D8 -> D8 addD8 (# x0, x1, x2, x3, x4, x5, x6, x7 #) (# y0, y1, y2, y3, y4, y5, y6, y7 #) = (# x0 +## y0, x1 +## y1, x2 +## y2, x3 +## y3, x4 +## y4, x5 +## y5, x6 +## y6, x7 +## y7 #) {-# NOINLINE addD8 #-} addD64 :: D64 -> D64 -> D64 addD64 (# x0, x1, x2, x3, x4, x5, x6, x7 #) (# y0, y1, y2, y3, y4, y5, y6, y7 #) = (# addD8 x0 y0, addD8 x1 y1, addD8 x2 y2, addD8 x3 y3, addD8 x4 y4, addD8 x5 y5, addD8 x6 y6, addD8 x7 y7 #) {-# NOINLINE addD64 #-} toListD8 :: D8 -> [Double] toListD8 (# x0, x1, x2, x3, x4, x5, x6, x7 #) = [D# x0, D# x1, D# x2, D# x3, D# x4, D# x5, D# x6, D# x7] {-# NOINLINE toListD8 #-} toListD64 :: D64 -> [Double] toListD64 (# x0, x1, x2, x3, x4, x5, x6, x7 #) = concat [toListD8 x0, toListD8 x1, toListD8 x2, toListD8 x3, toListD8 x4, toListD8 x5, toListD8 x6, toListD8 x7] {-# NOINLINE toListD64 #-} main :: IO () main = do let n = 64 let !x = mkD64 0 !y = mkD64 n print $ toListD64 x print $ toListD64 y print $ toListD64 (addD64 x y) print $ toListD64 x == [0..n-1] print $ toListD64 y == [n..2*n-1] print $ toListD64 (addD64 x y) == zipWith (+) [0..n-1] [n..2*n-1] ``` ``` $ javascript-unknown-ghcjs-ghc -fforce-recomp -O2 T26537_small.hs [1 of 2] Compiling Main ( T26537_small.hs, T26537_small.o ) [2 of 2] Linking T26537_small.jsexe $ node T26537_small.jsexe/all.js [0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0,32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0,52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0] [64.0,65.0,66.0,67.0,68.0,69.0,70.0,71.0,72.0,73.0,74.0,75.0,76.0,77.0,78.0,79.0,80.0,81.0,82.0,83.0,84.0,85.0,86.0,87.0,88.0,89.0,90.0,91.0,92.0,93.0,94.0,95.0,96.0,97.0,98.0,99.0,100.0,101.0,102.0,103.0,104.0,105.0,106.0,107.0,108.0,109.0,110.0,111.0,112.0,113.0,114.0,115.0,116.0,117.0,118.0,119.0,120.0,121.0,122.0,123.0,124.0,125.0,126.0,127.0] uncaught exception in Haskell main thread: ReferenceError: h$$ca430042 is not defined ReferenceError: h$$ca430042 is not defined at h$mainZCMainziaddD64_e (.../ghc/T26537_small.jsexe/all.js:62790:1) at h$runThreadSlice (.../ghc/T26537_small.jsexe/all.js:16342:11) at h$runThreadSliceCatch (.../ghc/T26537_small.jsexe/all.js:16294:12) at h$mainLoop (.../ghc/T26537_small.jsexe/all.js:16289:9) at .../ghc/T26537_small.jsexe/all.js:16832:13 at .../ghc/T26537_small.jsexe/all.js:9038:17 at FSReqCallback.wrapper [as oncomplete] (node:fs:815:5) ``` If I build the compiler without `-DDEBUG`, the generated code for `T26537.hs` fails with a ReferenceError too. ## Expected behavior The program should compile and run. ## Environment * GHC version used: 9.15.20251108 (ac7b737e8da74b2508994867ede0becb387cfc47) * Operating System: macOS * System Architecture: AArch64
issue