Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

ClojureScript 1.10.339
cljs.user=> (defn foo ([x] [:single x]) ([& xs] [:variadic xs]))


cljs.user=> (foo 1)
[:single 1]
cljs.user=> (foo 1 2)
[:variadic 1]

Note that the variadic call provides the wrong answer.

It appears that the right thing to do is not "make it work" but to reject the code as incorrect. See Clojure:

user=> (defn foo ([x] [:single x]) ([& xs] [:variadic xs])) CompilerException java.lang.RuntimeException: Can't have fixed arity function with more params than variadic function, compiling:(NO_SOURCE_PATH:1:1)

1 Answer

0 votes
Reference: https://clojure.atlassian.net/browse/CLJS-2863 (reported by mfikes)