encore icon indicating copy to clipboard operation
encore copied to clipboard

defalias doesn't work as expected in ClojureScript

Open viebel opened this issue 3 years ago • 8 comments

Reproduction steps:

$ clj -Sdeps '{:deps {com.taoensso/encore {:mvn/version "3.9.2"}}}' -m cljs.main --repl-env node                                                                                                                                     
WARNING: When invoking clojure.main, use -M
ClojureScript 1.10.339
cljs.user=> (require '[taoensso.encore :refer [defalias]])
nil
cljs.user=> (defalias foo map)
#'cljs.user/foo
cljs.user=> (meta #'foo)
{:ns cljs.user, :name foo, :file "<cljs repl>", :end-column 14, :source "foo", :column 1, :line 1, :end-line 1, :arglists (), :doc nil, :test nil}

The docstring metadata from #map was not attached to #'foo

viebel avatar Dec 28 '20 04:12 viebel

Hi Yehonathan,

Thanks for the report. It's not immediately obvious to me what the issue could be, could you please also include your output for (meta #'map)?

Thanks!

ptaoussanis avatar Dec 28 '20 09:12 ptaoussanis

Just pushed [com.taoensso/encore "3.9.3-alpha1"] to Clojars- would you please also try that and let me know if it solves the issue? Thanks!

ptaoussanis avatar Dec 28 '20 09:12 ptaoussanis

@ptaoussanis Issue still there

viebel avatar Dec 28 '20 10:12 viebel

👍 Could you please also include your output for (meta #'map)?

ptaoussanis avatar Dec 28 '20 10:12 ptaoussanis

Here is the full output:

clj -Sdeps '{:deps {com.taoensso/encore {:mvn/version "3.9.3-alpha1"}}}' -m cljs.main --repl-env node                                                                                                        [12:00:50]
DEPRECATED: Libs must be qualified, change tubular => tubular/tubular (/Users/viebel/.clojure/deps.edn)

Downloading: com/taoensso/encore/3.9.3-alpha1/encore-3.9.3-alpha1.pom from clojars
Downloading: com/taoensso/encore/3.9.3-alpha1/encore-3.9.3-alpha1.jar from clojars
WARNING: When invoking clojure.main, use -M
ClojureScript 1.10.339
cljs.user=> (require '[taoensso.encore :refer [defalias]])
nil
cljs.user=>(defalias foo map)
#'cljs.user/foo
cljs.user=> (meta #'foo)
{:ns cljs.user, :name foo, :file "<cljs repl>", :end-column 14, :source "foo", :column 1, :line 1, :end-line 1, :arglists (), :doc nil, :test nil}
cljs.user=> (meta #'map)
{:ns cljs.core, :name map, :file "cljs/core.cljs", :end-column 10, :top-fn {:variadic true, :max-fixed-arity 4, :method-params ([f] [f coll] [f c1 c2] [f c1 c2 c3]), :arglists ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]), :arglists-meta (nil nil nil nil nil)}, :column 1, :line 4654, :end-line 4654, :arglists ([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]), :doc "Returns a lazy sequence consisting of the result of applying f to\n  the set of first items of each coll, followed by applying f to the\n  set of second items in each coll, until any one of the colls is\n  exhausted.  Any remaining items in other colls are ignored. Function\n  f should accept number-of-colls arguments. Returns a transducer when\n  no collection is provided.", :test nil}
cljs.user=>

viebel avatar Dec 28 '20 11:12 viebel

Just pushed [com.taoensso/encore "3.10.1"] which should address this, with some limitations:

  • Cljs macros can't be aliased.
  • For Cljs docstring to work, the provided source must be fully qualified.

ptaoussanis avatar Dec 29 '20 15:12 ptaoussanis

I still cannot make it work

clj -Sdeps '{:deps {com.taoensso/encore {:mvn/version "3.10.1"}}}' -m cljs.main --repl-env node                                                                                                      [17:58:10]
DEPRECATED: Libs must be qualified, change tubular => tubular/tubular (/Users/viebel/.clojure/deps.edn)
Downloading: com/taoensso/encore/3.10.1/encore-3.10.1.pom from clojars
Downloading: com/taoensso/encore/3.10.1/encore-3.10.1.jar from clojars
WARNING: When invoking clojure.main, use -M
ClojureScript 1.10.339
cljs.user=> (require '[taoensso.encore :refer [defalias]])

nil
cljs.user=> cljs.user=> (defalias foo cljs.core/map)
#'cljs.user/foo
cljs.user=> (meta #'foo)
{:arglists (), :file "<cljs repl>", :ns cljs.user, :doc nil, :line 1, :column 1, :name foo, :test nil}

viebel avatar Dec 29 '20 16:12 viebel

Hi there! Okay, will re-open and try look at this more closely next time I have an opportunity for some open source.

3.10.1 works okay for me, but I'm not using clj - and couldn't get your command there to successfully run locally for some reason. (I don't use clj, so not too familiar with it).

I guess that this might specifically be a REPL issue - but will try dig more.

ptaoussanis avatar Jan 21 '21 11:01 ptaoussanis

Docstrings should now be properly retained in Cljs with [com.taoensso/encore "3.38.0"] 👍

ptaoussanis avatar Nov 21 '22 16:11 ptaoussanis