Skip to content

JavaScript: MK_JSVAL is implemented incorrectly

In GHC.StgToJS.Linker.Utils, we define MK_JSVAL, which is intended to take a JavaScript object, and wrap it with the base.GHC.Prim.JSVal data constructor.

Currently, the implementation we have is:

  , if profiling
      then "#define MK_JSVAL(x) (h$baseZCGHCziJSziPrimziJSVal_con_e, (x), h$CCS_SYSTEM)\n"
      else "#define MK_JSVAL(x) (h$baseZCGHCziJSziPrimziJSVal_con_e, (x))\n"

This looks to be a typo of the GHCJS implementation. To apply a data constructor in the JavaScript RTS, we expect to see a use of the h$c family ("constructor apply") of functions. Therefore, the implementation should be:

  , if profiling
      then "#define MK_JSVAL(x) (h$c1(h$baseZCGHCziJSziPrimziJSVal_con_e, (x), h$CCS_SYSTEM))\n"
      else "#define MK_JSVAL(x) (h$c1(h$baseZCGHCziJSziPrimziJSVal_con_e, (x)))\n"
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information