Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macros that expand to a def call: resulting var missing :line metadata #801

Closed
retrogradeorbit opened this issue Sep 22, 2022 · 1 comment

Comments

@retrogradeorbit
Copy link
Member

version

0.4.33

platform

JVM, linux binary

problem

In macros that expand to a def call, the resulting var is missing the :line metadata

repro

(defmacro foodef [sym & body]
  `(def ~sym ~@body))

(foodef x 1)

(prn (meta #'x))
Babashka v0.9.163-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (defmacro foodef [sym & body]
  `(def ~sym ~@body))
#'user/foodef
user=> (foodef x 1)
#'user/x
user=> (meta #'x)
{:name x, :ns #object[sci.lang.Namespace 0x11e36c1c "user"], :file "<repl>"}

expected behavior

in clojure:

Clojure 1.11.1
user=> (defmacro foodef [sym & body]
  `(def ~sym ~@body))
#'user/foodef
user=> (foodef x 1)
#'user/x
user=> (meta #'x)
{:line 1, :column 1, :file "NO_SOURCE_PATH", :name x, :ns #object[clojure.lang.Namespace 0xf9b5552 "user"]}

Comes from this babashka ticket: babashka/babashka#1367

@retrogradeorbit
Copy link
Member Author

retrogradeorbit commented Sep 22, 2022

meta data is also missing from def without macro

Babashka v0.9.163-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (def a 1)
#'user/a
user=> (meta #'a)
{:name a, :ns #object[sci.lang.Namespace 0x452d6fd "user"], :file "<repl>"}
user=> 

vs clojure

Clojure 1.11.1
user=> (def a 1)
#'user/a
user=> (meta #'a)
{:line 1, :column 1, :file "NO_SOURCE_PATH", :name a, :ns #object[clojure.lang.Namespace 0x22175d4f "user"]}
user=> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant