Fork me on GitHub
#cherry
<
2022-11-09
>
alex18:11:19

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)))))

borkdude18:11:12

Issue welcome. Might be something in SCI

1
alex18:11:43

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));

borkdude18:11:08

ehm.... should be...

borkdude18:11:41

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 tonight

1
borkdude18:11:08

I think this is a recent regression

alex18:11:14

Gotcha. Maybe from the aliases stuff I was doing? I definitely could have messed something up...

borkdude19:11:44

No worries :) I don't think it's anything you changed, and even if it was, there should have been a test catching this

borkdude19:11:27

It seems like an advanced compilation issue

borkdude20:11:31

So it seems it's an issue with shadow-cljs

borkdude21:11:07

@UGGU8TSMC both 78 and 79 are now fixed and published to npm

alex22:11:51

Thank you! that's interesting re: "EQ" and "=" conflict re: 78, I am still getting the same invalid arity issue after installing alpha59

borkdude22:11:46

hm ok, I'll try again tomorrow

borkdude22:11:47

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

borkdude22:11:35

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

💡 1
borkdude22:11:43

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: 30

borkdude22:11:59

This is what I do to work around it:

cljs.user=> (apply (.-afn f) (range 30))
nil

borkdude22:11:09

and this should have worked in 59, but I'm not sure why it didn't

alex22:11:49

What would be considered the function w/ metadata in this macro?

(defmacro do!
  [& exprs]
  `(do
     ~@(map (fn [expr#] `(js/await ~expr#)) exprs)))

borkdude22:11:51

In SCI, macros are functions with metadata, namely {:macro true}

💡 1
borkdude22:11:36

I'll take another look tomorrow 💤

alex22:11:58

No rush. I have the wrap-them-in-a-fn workaround 🙂 Ty!