hyperfiddle/electric

Attempt to define e/fn with variable arity results in wrong error message

beders opened this issue · 2 comments

Using the electric-start-app (with electric on latest).
This code is generating the following error:

You called bar, a 4-arg e/fn with 3 arguments.

 in ( hyperfiddle.electric/-check-fn-arity! bar 4 3 ) in app/crash.cljc
 in reactive (defn bar [tag props & rest] ...) in app/crash.cljc line 14
 in reactive (fn [] ...)
 in reactive (defn Example [] ...) in app/crash.cljc line 17
 in (try ...) 

Code:

(ns app.crash
  (:require [hyperfiddle.electric :as e]
            [hyperfiddle.electric-dom2 :as dom]))

(e/defn bar [tag props & rest]
  (dom/div "hi"))

(e/defn Example []
  (e/server
   (binding []
     (e/client
      (dom/div
        (bar. :h1 {} "hi")
        ))
     )))

Calling (bar. :h1 {} "foo" "bar") works

I dont think we support varargs yet. We will improve the error.

Varargs implemented and released