Description
Expected behavior
Typing math/ in a CLJC file should insert the libspec [clojure.math :as math]
into the ns form.
Actual behavior
The libspec inserted is #?(:clj [clojure.math :as math])
.
Steps to reproduce the problem
Using clj-refactor in a CLJC file type math/
in a namespace with no existing alias named math.
Commentary
This is using a default cljr-magic-require-namespaces
which does not specify clojure.math as :only ("clj")
but does include it as a magic namespace. This works correctly for clojure.set :as set
and clojure.string :as str
and even clojure.walk
and clojure.zip
, which are also listed in the magic namespaces, so it's confusing that clojure.math
behaves differently. The project I'm testing with has a mixture of cljs and cljc files but has no instances where the math libspec is wrapped in a reader conditional. It does correctly return clojure.math :as math in cljs files in that project, but add the unnecessary :clj language conditional if math/
invokes cljr-slash
in a CLJC file.
Note that clojure.math is one of the CLJS namespaces that is magically mapped to the equivalent namespace in Clojure as described in https://clojurescript.org/guides/ns-forms#_clojure_namespace_aliasing. I don't know if that's related but it seems like it might be.
Environment & Version information
clj-refactor.el and refactor-nrepl version information
clj-refactor 3.11.3, refactor-nrepl 3.10.0
CIDER version information
;; CIDER 1.14.0-snapshot (package: 20240510.1436), nREPL 1.1.1
;; Clojure 1.11.1, Java 17.0.10
Emacs version
GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.18.0) of 2024-05-08
Operating system
Ubuntu 23.10