> (meta (second '(a #^b c)))
nil
In 1.1.0-new (and I believe all previous versions)
> (meta (second '(a #^b c)))
{:tag b}
Is this intentional, or a bug? Is the new type hint syntax being
introduced in 1.2?
user> [*clojure-version* (meta (second '(a #^b c)))]
[{:interim true, :major 1, :minor 2, :incremental 0, :qualifier
"master"} {:tag b}]
user=> [*clojure-version* (meta (second '(a #^b c)))]
[{:interim true, :major 1, :minor 2, :incremental 0, :qualifier
"master"} nil]
Does anyone have an idea what's going on here?
I think it's a bug, perhaps related to quoting behavior.
Everything seems to work okay before this commit:
commit 430dd4fa711d0008137d7a82d4b4cd27b6e2d6d1
Author: Rich Hickey <richh...@gmail.com>
Date: Tue Jan 19 14:25:26 2010 -0500
metadata for fns
Afterward:
(meta '#^a b)
;=> nil
(meta '#^{:foo :bar} [5 10])
;=> nil
(meta (first '[#^{:foo :bar} {}]))
;=> nil
This, however, works both before and after:
(meta #^{:foo :bar} [5 10])
;=> {:foo :bar}
Also, the problem appears to be related to 'eval' not 'read':
(second (read-string "(quote #^a b))"))
;=> b
(meta (second (read-string "(quote #^a b))")))
;=> {:tag a}
(eval (read-string "(quote #^a b))"))
;=> b
(meta (eval (read-string "(quote #^a b))")))
;=> nil
--Chouser
PersistentLists and PersistentHashSets work, but other things fail.
I think i know the reason:
Compiler.emitValue() (Compiler.java:3741-3879) is for initializing
constant expressions, but it only adds metadata, if the value is an
instance of class Obj (Compiler.java:3870). But since commit
430dd4fa711d0008137d7a82d4b4cd27b6e2d6d1 (metadata for fns) AFn no
longer extends Obj, and thus Maps, Symbols and Vectors aren't
instances of Obj anymore.
PersistentList extends ASeq which extends Obj directly, so those work.
No idea why PersistentSet works however.
AlexK
I think you nailed it. Changing Obj to IObj on lines 3870 and
3873 seems to fix it.
--Chouser
http://joyofclojure.com/
Fixed - thanks all.
Rich