in a cljc file, i have a macro that i'm self-requiring with (:require-macros lazytest.core), and then i'm later using in functions. when i compile the file with cljs, there's no warning, but when i compile with shadow-cljs, i see :undeclared-var warnings:
------ WARNING #6 - :undeclared-var --------------------------------------------
File: /Users/noah/programming/lazytest/src/clojure/lazytest/core.cljc:449:30
--------------------------------------------------------------------------------
446 | msg
447 | {:message msg
448 | :file #?(:clj *file* :cljs (.-fileName (js/Error. "")))
449 | :ns (current-ns)
------------------------------------^-------------------------------------------
Can't take value of macro lazytest.core/current-ns
in what way is this a "take value of macro"? why isn't this being executed/replaced when the file is parsed?I can't say without seeing the code in context. what is current-ns? its not a core function
(defmacro current-ns []
(ns-name *ns*))
;;; Utilities
(defn ^:no-doc merged-data
"For internal use only."
[body form docstring metadata]
(merge {:doc docstring
:file #?(:clj *file* :cljs (.-fileName (js/Error. "")))
:ns (current-ns)}
(when (empty? body) {:pending true})
(meta form)
{:metadata metadata}))
uhm that won't work. I mean it'll always be lazytest.core
thats as if you had written
(defn ^:no-doc merged-data
"For internal use only."
[body form docstring metadata]
(merge {:doc docstring
:file #?(:clj *file* :cljs (.-fileName (js/Error. "")))
:ns "lazytest.core"}
(when (empty? body) {:pending true})
(meta form)
{:metadata metadata}))damn
hmm thats even true in clojure?
well, it was previously just *ns* so i'm trying to make something dialectical
if thats from a macro context use that macros &env to get (:name (:ns &env)) or *ns* captured during macro expansion. can't do it in a defn
so having a macro that calls (:name (:ns &env)) isn't enough if it's used in a defn context? it'll carry the defn context forward?
looks like that is a function that only runs during macro expansion? so *ns* should be fine no?
looking at https://github.com/NoahTheDuke/lazytest/blob/main/src/clojure/lazytest/core.clj#L245 I mean
huh looks like you're correct, i didn't think about that
i think i was trying to avoid that because i've been seeing this error
8 | (defdescribe expectation-failed-test
-------^------------------------------------------------------------------------
An error occurred while generating code for the form.
ExceptionInfo: failed compiling constant: lazytest.expectation-failed-test; clojure.lang.Namespace is not a valid ClojureScript constant.
cljs.compiler/fn--4209 (compiler.cljc:307)
cljs.compiler/fn--4209 (compiler.cljc:304)
clojure.lang.MultiFn.invoke (MultiFn.java:229)
cljs.compiler/emit-constant-no-meta (compiler.cljc:286)
...
well yeah. use (ns-name *ns*) since you only want the string I presume
and put that function into a #?(:clj ...) so the CLJS compilation doesn't choke on that