Fork me on GitHub
Yehonathan Sharvit12:04:42

Something weird happens with static-fns true

Yehonathan Sharvit12:04:58

In some cases, we end up using call

Yehonathan Sharvit12:04:13

(f)` becomes (cljs.user.f.cljs$core$IFn$_invoke$arity$0 ? cljs.user.f.cljs$core$IFn$_invoke$arity$0() :;

Yehonathan Sharvit12:04:30

At run time, it will be

Yehonathan Sharvit12:04:46

Because cljs.user.f.cljs$core$IFn$_invoke$arity$0 is undefined

Yehonathan Sharvit12:04:07

while (g) will be cljs.user.g.cljs$core$IFn$_invoke$arity$0()


@viebel: that’s how it’s supposed to work, I talked about this behavior the other day


it’s an optimization for higher order function calls where it’s not possible to know the arity statically


FWIW, I revised the else branch to look like f "(" (comma-sep args) "))” and it works in this particular case and for the compiler unit tests (in other words, it blindly makes a static call if the desired arity is not found). Perhaps the assumption that it is a non-multi-arity function misses corner cases though, and even though :static-fns true is enabled, it is safer to dynamically dispatch.