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

0 votes
in ClojureScript by

In

(fn [& xs] (if xs 1 2))

no type will be inferred for the {{xs}} param. If we instead infer it to be of type {{seq}} then an unchecked {{if}} can be emitted. (An example of code like this involving an unnecessary check in {{if}} is in the variadic arity of {{str}}.)

While a change such as this wouldn't have a huge perf impact, it could slightly reduce generated code size and it could lead to better diagnostics for incorrect code:

cljs.user=> (fn [& xs] (+ xs 1)) WARNING: cljs.core/+, all arguments must be numbers, got [seq number] instead at line 1 <cljs repl>

3 Answers

0 votes
by

Comment made by: mfikes

CLJS-2961.patch passes CI and Canary, and shows no compiler slowdown when compiling Coal Mine.

0 votes
by

Comment made by: mfikes

CLJS-2961.patch added to Patch Tender (i)

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