Skip to content

Commit e9874ba

Browse files
jonaseswannodette
authored andcommitted
CLJS-601: Function overloaded with same arity count now fails to compile.
1 parent 999da27 commit e9874ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/clj/cljs/analyzer.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,10 @@
478478
;; lets us optimize self calls
479479
(no-warn (doall (map #(analyze-fn-method menv locals % type) meths)))
480480
methods)]
481-
;;todo - validate unique arities, at most one variadic, variadic takes max required args
481+
;;todo - at most one variadic, variadic takes max required args
482+
(let [param-counts (map (comp count :params) methods)]
483+
(when (not= (distinct param-counts) param-counts)
484+
(throw (error env "Can't have 2 overloads with same arity"))))
482485
{:env env :op :fn :form form :name name-var :methods methods :variadic variadic
483486
:recur-frames *recur-frames* :loop-lets *loop-lets*
484487
:jsdoc [(when variadic "@param {...*} var_args")]

0 commit comments

Comments
 (0)