squint
squint copied to clipboard
Unchecked set + multiarity function is broken
(unchecked-set js/global "foo" (fn ([]) ([a])))
Expected result: It outputs valid JS
Actual result: Fails with the following message
(global["foo"] = let f1 = function (var_args) {
^^^
SyntaxError: Unexpected strict mode reserved word
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:483:14)
at async link (node:internal/modules/esm/module_job:67:21)
You can work around this for now by binding the function in a let:
(let [x (fn ...)] x)
Seems to work now:
$ ./node_cli.js -e '(unchecked-set js/global "foo" (fn ([]) ([a] a))) (prn (foo 1))'
1