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

0 votes
in ClojureScript by

Hello,

The following code emits a warning in clojurescript when it should not:

(defrecord A [])
(A. {:tag 1} nil)
WARNING: Wrong number of args (2) passed to A at line 1 <cljs repl>

The docstring states:

Two constructors will be defined, one taking the designated fields
followed by a metadata map (nil for none) and an extension field
map (nil for none), and one taking only the fields (using nil for
meta and extension fields).

And the meta is correctly applied:

(meta (A. {:tag 1} nil))
WARNING: Wrong number of args (2) passed to A at line 1 <cljs repl>
{:tag 1}

This is due to the check here

I will happily provide a patch for the issue.

1 Answer

0 votes
by
selected by
 
Best answer

The docstring says the constructor will take: designated fields AND a metadata map AND an extension field map, so it should have either 1 or 3 args. You've passed 2. This should work:

(meta (A. {:tag 1} nil nil))
by
In my example the record has 0 "designated fields". `{:tag 1}` was the metadata. And I still get the warning if I use `(A. {:tag 1} nil nil)`
by
Ah ok, I see, I'll file a ticket.
...