Closed
Description
Hi,
there appears to be an issue when trying to set metadata on an ns
form directly:
error occurred during macroexpansion: tuple index out of range
to reproduce,
- create an
issue.lpy
file in asys.path
directory, declaring a namespace with metadata attached to its name
(ns ^:xyz issue)
(println :hi)
- Open the REPL and try to require the namespace, the above error is raised
> basilisp repl
basilisp.user=> (require 'issue)
exception: <class 'IndexError'> from <class 'basilisp.lang.compiler.exception.CompilerException'>
phase: :macroexpansion
message: error occurred during macroexpansion: tuple index out of range
form: (ns issue)
location: C:\src\basilisp\src\issue.lpy:1
context:
1 > | (ns ^:xyz issue)
2 |
3 | (println :hi)
In contrast, the same works fine in Clojure
> clj
Clojure 1.12.0
user=> (require 'issue)
:hi
nil
user=> (in-ns 'issue)
#object[clojure.lang.Namespace 0x3e48e859 "issue"]
issue=> (meta *ns*)
{:xyz true}
This used to work before, so I think it is a regression issue likely introduced by #1161?
Additionaly, in Clojure, The attr-map?
option appears to overwrite any metadata set earlier in Clojure:
issue.clj
(ns ^{:abc 1 :xyz 2} issue "doc" {:abc 2})
(println :hi)
REPL:
> clj
Clojure 1.12.0
user=> (require 'issue)
:hi
nil
user=> (in-ns 'issue)
#object[clojure.lang.Namespace 0x5b22b970 "issue"]
issue=> (meta *ns*)
{:abc 2, :xyz 2, :doc "doc"}
It is not clear to me why the ns
macro supports both explicit metadata and the attr-map?
option, as the seem to serer similar purposes.
Thanks