<!-- 
RSS generated by JIRA (4.4#649-r158309) at Fri May 24 13:09:14 CDT 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://dev.clojure.org/jira/si/jira.issueviews:issue-xml/CLJ-270/CLJ-270.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Clojure JIRA</title>
    <link>http://dev.clojure.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>4.4</version>
        <build-number>649</build-number>
        <build-date>25-07-2011</build-date>
    </build-info>

<item>
            <title>[CLJ-270] defn-created fns inherit old metadata from the Var they are assigned to</title>
                <link>http://dev.clojure.org/jira/browse/CLJ-270</link>
                <project id="10010" key="CLJ">Clojure</project>
                        <description>&lt;ul&gt;
	&lt;li&gt;What (small set of) steps will reproduce the problem?&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;user&amp;gt; (def #^{:foo &quot;bar&quot;} x 5)&lt;br/&gt;
#&apos;user/x&lt;br/&gt;
user&amp;gt; (meta #&apos;x)&lt;br/&gt;
{:ns #&amp;lt;Namespace user&amp;gt;, :name x, :file &quot;NO_SOURCE_FILE&quot;, :line 1, :foo &quot;bar&quot;}&lt;br/&gt;
user&amp;gt; (defn x [] 5)&lt;br/&gt;
#&apos;user/x&lt;br/&gt;
user&amp;gt; (meta #&apos;x)&lt;br/&gt;
{:ns #&amp;lt;Namespace user&amp;gt;, :name x, :file &quot;NO_SOURCE_FILE&quot;, :line 1, :arglists ([])}&lt;br/&gt;
user&amp;gt; (meta x)&lt;br/&gt;
{:ns #&amp;lt;Namespace user&amp;gt;, :name x, :file &quot;NO_SOURCE_FILE&quot;, :line 1, :foo &quot;bar&quot;}&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;What is the expected output? What do you see instead?&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I expect (meta #&apos;x) to evaluate to the value of the final (meta x) in the above.&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;What version are you using?&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Current master (commit 61202d2ff6925002400a9843e8fbd080f3bef3a5).&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Was this discussed on the group? If so, please provide a link to the discussion.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&lt;a href=&quot;http://groups.google.com/group/clojure/browse_thread/thread/4c7151aa9c4d919c/d1b033ef5a13dd89?lnk=gst&amp;amp;q=off-by-one#d1b033ef5a13dd89&quot;&gt;http://groups.google.com/group/clojure/browse_thread/thread/4c7151aa9c4d919c/d1b033ef5a13dd89?lnk=gst&amp;amp;q=off-by-one#d1b033ef5a13dd89&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Prompted by discussion at&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://groups.google.com/group/clojure/browse_thread/thread/6553d48c981019eb/3c55b0bd43a5d8e9?lnk=gst&amp;amp;q=off-by-one#3c55b0bd43a5d8e9&quot;&gt;http://groups.google.com/group/clojure/browse_thread/thread/6553d48c981019eb/3c55b0bd43a5d8e9?lnk=gst&amp;amp;q=off-by-one#3c55b0bd43a5d8e9&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;Initial attempt at a diagnosis:&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I think this is due to DefExpr&apos;s eval method binding the Var to init.eval() first and attaching the supplied metadata to the Var later &amp;#8211; see Compiler.java lines 341-352. (Note the Var is always already in place when init.eval() is called, regardless of whether it existed prior to the evaluation of the def / defn.) Thus the init expression supplied by defn sees the old (and wrong) metadata on the Var.&lt;/p&gt;</description>
                <environment></environment>
            <key id="13667">CLJ-270</key>
            <summary>defn-created fns inherit old metadata from the Var they are assigned to</summary>
                <type id="1" iconUrl="http://dev.clojure.org/jira/images/icons/bug.gif">Defect</type>
                                        <status id="1" iconUrl="http://dev.clojure.org/jira/images/icons/status_open.gif">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="richhickey">Rich Hickey</assignee>
                                <reporter username="-1">None</reporter>
                        <labels>
                    </labels>
                <created>Sat, 13 Feb 2010 19:05:00 -0600</created>
                <updated>Tue, 24 Aug 2010 06:23:00 -0500</updated>
                                                    <fixVersion>Approved Backlog</fixVersion>
                                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="23509" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;Converted from &lt;a href=&quot;http://www.assembla.com/spaces/clojure/tickets/270&quot;&gt;http://www.assembla.com/spaces/clojure/tickets/270&lt;/a&gt;&lt;br/&gt;
Attachments:&lt;br/&gt;
dont-copy-val-metadata-onto-new-var-value-in-defn.patch - &lt;a href=&quot;https://www.assembla.com/spaces/clojure/documents/dwK4yssayr37y_eJe5d-aX/download/dwK4yssayr37y_eJe5d-aX&quot;&gt;https://www.assembla.com/spaces/clojure/documents/dwK4yssayr37y_eJe5d-aX/download/dwK4yssayr37y_eJe5d-aX&lt;/a&gt;&lt;br/&gt;
0001-set-meta-on-vars-before-evaluating-their-init-see-27.patch - &lt;a href=&quot;https://www.assembla.com/spaces/clojure/documents/arrhbiAI4r35lQeJe5cbLr/download/arrhbiAI4r35lQeJe5cbLr&quot;&gt;https://www.assembla.com/spaces/clojure/documents/arrhbiAI4r35lQeJe5cbLr/download/arrhbiAI4r35lQeJe5cbLr&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="23510" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;stu said: [&lt;a href=&quot;file:dwK4yssayr37y_eJe5d-aX&quot;&gt;file:dwK4yssayr37y_eJe5d-aX&lt;/a&gt;]&lt;/p&gt;</comment>
                    <comment id="23511" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;stu said: The problem happens with defn, but not with def+fn, so I think the original diagnosis is incorrect. &lt;/p&gt;

&lt;p&gt;Another stab at diagnosis: The defn macro copies metadata from a var onto its new value, so if you defn a var that already exists, the old var metadata becomes metadata on the new value. I don&apos;t know why this would be the right thing to do, and if you eliminate this behavior (see patch) all the Clojure and Contrib tests still pass.&lt;/p&gt;

&lt;p&gt;If this is correct, please assign back to me and I will write tests. If this is wrong, please tell me what&apos;s going on here so I know how to write the tests.&lt;/p&gt;</comment>
                    <comment id="23512" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;cgrand said: &lt;b&gt;Child&lt;/b&gt; association with ticket #363 was added&lt;/p&gt;</comment>
                    <comment id="23513" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;cgrand said: I think the original diagnosis is correct. Note that the behavior differ when def iscompiled:&lt;/p&gt;

&lt;p&gt;user=&amp;gt; (def #^{:foo &quot;bar&quot;} x 5)&lt;br/&gt;
#&apos;user/x&lt;br/&gt;
user=&amp;gt; (let [] (defn x [] 5))&lt;br/&gt;
#&apos;user/x&lt;br/&gt;
user=&amp;gt; (meta x)&lt;br/&gt;
{:ns #&amp;lt;Namespace user&amp;gt;, :name x, :file &quot;NO_SOURCE_PATH&quot;, :line 83, :arglists ([])}&lt;br/&gt;
user=&amp;gt; (meta #&apos;x)&lt;br/&gt;
{:ns #&amp;lt;Namespace user&amp;gt;, :name x, :file &quot;NO_SOURCE_PATH&quot;, :line 83, :arglists ([])}&lt;/p&gt;

&lt;p&gt;See also &lt;a href=&quot;http://groups.google.com/group/clojure/browse_thread/thread/6afd81896ca368b2#&quot;&gt;http://groups.google.com/group/clojure/browse_thread/thread/6afd81896ca368b2#&lt;/a&gt;&lt;/p&gt;</comment>
                    <comment id="23514" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;cgrand said: [&lt;a href=&quot;file:arrhbiAI4r35lQeJe5cbLr&quot;&gt;file:arrhbiAI4r35lQeJe5cbLr&lt;/a&gt;]&lt;/p&gt;</comment>
                    <comment id="23515" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;cgrand said: My patch aligns DefExpr.eval with DefExpr.emit (first set meta then eval the init value).&lt;/p&gt;</comment>
                    <comment id="23516" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;cgrand said: Forget it, my current patch is broken.&lt;/p&gt;</comment>
                    <comment id="23517" author="importer" created="Tue, 24 Aug 2010 06:23:00 -0500"  >&lt;p&gt;cgrand said: My current patch is broken because of #352, what is the rational for #352?&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                                                                                            </customfields>
    </item>
</channel>
</rss>