Reader attaches collection metadata to data, not a with-meta form
The reader lowered ^meta on a vector/map/set literal to a runtime (with-meta form meta) list, so read-string/edn of data with metadata returned the form and lost the metadata. Attach it to the value instead, as Clojure does; the analyzer re-emits (with-meta coll meta) for a meta-carrying collection literal in code, so a literal still carries its metadata at runtime and ^Type/^long arglist hints (consumed by analyze-arity directly) are unaffected. Also: pr honors *print-meta*, and clojure.walk/clojure.edn re-attach metadata to the collections they rebuild (matches Clojure; a metadata-driven config lib like aero relies on it).
This commit is contained in:
parent
091d2c4b62
commit
473d1002b7
8 changed files with 763 additions and 716 deletions
|
|
@ -86,6 +86,10 @@
|
|||
(define (hc-sym-meta x)
|
||||
(let ((m (symbol-t-meta x)))
|
||||
(if (and m (not (jolt-nil? m)) (not (null? m))) m jolt-nil)))
|
||||
;; Metadata the reader attached to a collection literal (vec/map/set/list), or
|
||||
;; jolt-nil. The analyzer re-emits a runtime (with-meta ..) for a meta-carrying
|
||||
;; vector/map/set so the value keeps its metadata.
|
||||
(define (hc-coll-meta x) (jolt-meta x))
|
||||
|
||||
;; list items -> jolt vector (pvec); the analyzer mapv's over the result.
|
||||
(define (hc-elements x)
|
||||
|
|
@ -327,6 +331,7 @@
|
|||
(def-var! "jolt.host" "form-sym-name" hc-sym-name)
|
||||
(def-var! "jolt.host" "form-sym-ns" hc-sym-ns)
|
||||
(def-var! "jolt.host" "form-sym-meta" hc-sym-meta)
|
||||
(def-var! "jolt.host" "form-coll-meta" hc-coll-meta)
|
||||
(def-var! "jolt.host" "form-list?" hc-list?)
|
||||
(def-var! "jolt.host" "form-vec?" hc-vec?)
|
||||
(def-var! "jolt.host" "form-map?" hc-map?)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue