<< Back to previous view

[CLJ-1196] eval of defrecord instance with no fields produces {}, not itself Created: 10/Apr/13  Updated: 10/Apr/13  Resolved: 10/Apr/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.5
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: Jason Wolfe Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None

Mac OS X Clojure 1.5.1


user> (defrecord Foo [])
user> (Foo.)
user> (eval (Foo.))

user> (defrecord Foo [a b])
user> (eval (Foo. 1 2))
#user.Foo{:a 1, :b 2}

As you can see, evaluating the record with no fields loses the type information. This came up in code that uses records to describe argument schema information for functions in a macro, with no direct use of 'eval'. It is unexpected because of the inconsistency between empty and non-empty defrecords, and because the Clojure docs say 'Any object other than those discussed above will evaluate to itself.'


I'm happy to elaborate on the use case if there are questions.

Comment by Nicola Mometto [ 10/Apr/13 5:11 AM ]

I think this is a duplicate of http://dev.clojure.org/jira/browse/CLJ-1093

Comment by Jason Wolfe [ 10/Apr/13 10:51 AM ]

You are right, sorry for the duplication. I searched for empty record in JIRA and somehow missed that ticket.

Comment by Andy Fingerhut [ 10/Apr/13 11:42 AM ]

Close as duplicate of CLJ-1093.

Generated at Fri Oct 09 18:50:18 CDT 2015 using JIRA 4.4#649-r158309.