EDIT: Will post to GH issues
I have the following do! macro that wraps individual exprs in js/await. When I have greater than ~20 expressions in the body of the do!, the compiler throws an error
(defmacro do!
[& exprs]
`(do
~@(map (fn [expr#] `(js/await ~expr#)) exprs)))
;; usage
(do!
(first-async-fn)
...
(twentieth-async-fn))
file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/cli.js:483
arguments[18],arguments[19],arguments[20],arguments[21]);default:throw Error(["Invalid arity: ",$APP.v.h(arguments.length-1)].join(""));}};$APP.g.apply=function(a,b){return this.call.apply(this,[this].concat($APP.ib(b)))};$APP.g.v=function(){var a=$APP.w(this);return a.v?a.v():a.call(null)};$APP.g.h=function(a){var b=$APP.w(this);return b.h?b.h(a):b.call(null,a)};$APP.g.g=function(a,b){var c=$APP.w(this);return c.g?c.g(a,b):c.call(null,a,b)};
Error: Invalid arity: 23
at VQ.$APP.g.call (file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/cli.js:483:72)
at VQ.$APP.g.apply (file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/cli.js:483:184)
at Xg (file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/cljs_core.js:551:491)
at Wg (file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/cljs_core.js:547:70)
at Ug (file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/cljs_core.js:546:421)
at Function.$APP.Ch.B (file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/cljs_core.js:793:404)
at file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/compiler.js:587:258
at file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/compiler.js:588:267
at $APP.kr.$APP.g.g (file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/compiler.js:213:289)
at file:///Users/alex/code/icebreaker/ui_tests/node_modules/cherry-cljs/lib/compiler.js:185:206
I'm able to work around this issue by wrapping a subset of the expressions (to get under ~20) into their own functions and invoking them i.e.
(do!
(^:async (fn []
(do!
(first-async-fn)
...
(tenth-async-fn)))
(^:async (fn []
(eleventh-async-fn)
...
(twentieth-async-fn)))))Is = & other comparators not supported yet?
(= 1 1)
1) [chromium] › cherry_playwright.spec.mjs:422:19 › stage host controls ==========================
ReferenceError: _EQ_ is not defined
> 444 | (await _EQ_.call(null, 1, 1));ehm.... should be...
I can repro the problem:
$ ./node_cli.js -e '(= 1 2)'
file:///Users/borkdude/dev/cherry/.tmpQ1aZ4r/cherry.mjs:1
_EQ_.call(null, 1, 2);
^
Issue welcome, will fix tonightI think this is a recent regression
Gotcha. Maybe from the aliases stuff I was doing? I definitely could have messed something up...
No worries :) I don't think it's anything you changed, and even if it was, there should have been a test catching this
It seems like an advanced compilation issue
So it seems it's an issue with shadow-cljs
@rahx1t both 78 and 79 are now fixed and published to npm
Thank you! that's interesting re: "EQ" and "=" conflict re: 78, I am still getting the same invalid arity issue after installing alpha59
hm ok, I'll try again tomorrow
I've encountered this issue before. The issue is that a function with metadata implements some protocol and protocol implementations can't have more than 20 arguments
but if you unwrap this function, using the .-afn field, you get the normal function which does support more than 20 args and this is what I've tried. This fix worked in SCI before, but I'll re-test it tomorrow
Here is a repro in cljs:
ClojureScript 1.10.914
cljs.user=> (def f (fn [x & xs]))
#'cljs.user/f
cljs.user=> (apply f (range 30))
nil
cljs.user=> (def f (with-meta (fn f [x & xs]) {}))
#'cljs.user/f
cljs.user=> (apply f (range 30))
Execution error (Error) at (<cljs repl>:1).
Invalid arity: 30This is what I do to work around it:
cljs.user=> (apply (.-afn f) (range 30))
niland this should have worked in 59, but I'm not sure why it didn't
What would be considered the function w/ metadata in this macro?
(defmacro do!
[& exprs]
`(do
~@(map (fn [expr#] `(js/await ~expr#)) exprs)))In SCI, macros are functions with metadata, namely {:macro true}
I'll take another look tomorrow 💤
No rush. I have the wrap-them-in-a-fn workaround 🙂 Ty!