Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 637
    • Merge requests 637
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #22814

"c is not a function" in Hello world with javascript backend

Summary

Running a hello world program with the new javascript backend fails

Steps to reproduce

  1. echo 'main = putStrLn "Hello world!"' > HelloWorld.hs
  2. ghcjs HelloWorld.hs
  3. ./HelloWorld
ghcjs-docker/test/HelloWorld:11562
                c(bytesWritten);
                ^

TypeError: c is not a function
    at test/HelloWorld:11562:17
    at FSReqCallback.wrapper [as oncomplete] (node:fs:815:5)

Node.js v19.4.0

To be completely specific, I've built GHC on commit 14b5982a in Docker: https://github.com/brandonchinn178/ghcjs-docker.

Printing out the arguments passed to h$base_writeFile shows c is 13:
[Arguments] {
  '0': 1,
  '1': {
    write: [Function: h$base_writeStdout],
    close: [Function: h$base_closeStdout],
    isatty: [Function: h$base_isattyStdout],
    refs: 1
  },
  '2': {
    buf: ArrayBuffer {
      [Uint8Contents]: <48 65 6c 6c 6f 20 77 6f 72 6c 64 21 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 8092 more bytes>,
      byteLength: 8192
    },
    len: 8192,
    i3: Int32Array(2048) [
      1819043144, 1870078063, 560229490, 10, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0, 0, 0,
               0,          0,         0,  0,
      ... 1948 more items
    ],
    u8: Uint8Array(8192) [
      72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33,
      10,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,  0,
       0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,  0,
       0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,  0,
       0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,  0,
       0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,  0,
       0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,  0,
       0,   0,   0,   0,   0,  0,   0,   0,   0,   0,   0,  0,
       0,   0,   0,   0,
      ... 8092 more items
    ],
    u1: Uint16Array(4096) [
      25928, 27756, 8303, 28535, 27762, 8548, 10, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
          0,     0,    0,     0,     0,    0,  0, 0, 0, 0,
      ... 3996 more items
    ],
    f3: Float32Array(2048) [
      1.1431391224375825e+27, 7.64820072347795e+28, 7.73929309656278e-19,
       1.401298464324817e-44,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,                    0,                    0,
                           0,
      ... 1948 more items
    ],
    f6: Float64Array(1024) [
      8.765776478827854e+228, 2.14967480544e-313, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,                  0, 0,
                           0,
      ... 924 more items
    ],
    dv: DataView { byteLength: 8192, byteOffset: 0, buffer: [ArrayBuffer] },
    m: 0
  },
  '3': 0,
  '4': 0,
  '5': 13
}

Expected behavior

Should work

Environment

Edited Jan 22, 2023 by Brandon Chinn
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking