Clojurians
#cljs-dev
<
2016-04-14
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

viebel12:04:42

Something weird happens with static-fns true

viebel12:04:58

In some cases, we end up using call

viebel12:04:44

is transpiled to

viebel12:04:13

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

viebel12:04:30

At run time, it will be cljs.user.f.call(null))

viebel12:04:46

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

viebel12:04:07

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

dnolen14:04:44

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

dnolen14:04:09

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

mfikes14:04:15

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.