Fork me on GitHub
#shadow-cljs
<
2024-03-15
>
Matthew Davidson (kingmob)17:03:50

Hmmm, has anyone encountered an error like this before?

------ WARNING #1 - :undeclared-var --------------------------------------------
 File: /Users/matthew/.gitlibs/libs/io.github.inferenceql/inferenceql.inference/40e77dedf680b7936ce988b66186a86f5c4db6a5/src/inferenceql/inference/gpm/conditioned.cljc:21:8
--------------------------------------------------------------------------------
  18 |   gpm.proto/Condition
  19 |   (condition [_ new-conditions]
  20 |     (let [merged-conditions (merge conditions new-conditions)]
  21 |       (->ConditionedGPM gpm merged-conditions))))
--------------^-----------------------------------------------------------------
 Use of undeclared Var inferenceql.inference.gpm.conditioned/->ConditionedGPM
--------------------------------------------------------------------------------
  22 |
  23 | (defn condition
  24 |   "Conditions gpm based on conditions via rejection sampling. Arguments are the
  25 |   same as those for `inferenceql.inference.gom/condition`."
--------------------------------------------------------------------------------
This in the middle of a (defrecord ConditionedGPM ...) , so it's just trying to construct and return a new instance of the same record. It's a cljc file, and it works just fine in Clojure, but I can't figure out why shadow is complaining. We don't have to declare the arrow constructors in cljs, right?

thheller19:03:00

might be a bug in CLJS. just swap ->ConditionedGPM to ConditionedGPM., that'll work in both envs

phill21:03:28

Or maybe use extend after the defrecord? I did not know it was possible to refer to the defrecord-generated constructor within the defrecord form!

Matthew Davidson (kingmob)07:03:31

@U05224H0W Yep, that worked. @U0HG4EHMH In clj, if you look at the defrecord macro, it emits a declare for the ->Foo and map->Foo symbols right off the bat. It looks like the cljs equivalent, build-positional-factory, doesn't happen until the end of the macro, which might be the cause.

Matthew Davidson (kingmob)08:03:17

Weird update: in Clojure, it's a compilation error with deftype, but not defrecord, which is weird.