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

+1 vote
in ClojureScript by
reshown by

I get a warning if I try to compile a defrecord where a method tries to call the arrow constructor.

This:

(defrecord Foo [a b]
  SomeProtocol
  (some-method [_]
    (->Foo new-a new-b)))

gives the message "WARNING: Use of undeclared Var some.ns/->Foo at line X". Clojure accepts this form ok.

If I switch to the dot constructor version, like (Foo. _ _) it compiles.

I noticed that in the clj defrecord macro, the symbols for ->Foo and map->Foo are declared first thing, but in cljs, the related build-positional-factory and build-map-factory fns are called at the end, after emit-defrecord. Perhaps that's the issue?

It looks like deftype should have a similar issue, but I haven't tested it.

by
edited by
Interestingly, in Clojure, deftype refuses to compile, while defrecord allows this.

Please log in or register to answer this question.

...