<< Back to previous view

[CLJ-693] VerifyError with symbol metadata, macros, and defrecord Created: 16/Dec/10  Updated: 26/Jul/13  Resolved: 17/Dec/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Backlog, Release 1.2, Release 1.3
Fix Version/s: Release 1.3

Type: Defect Priority: Major
Reporter: Constantine Vetoshev Assignee: Rich Hickey
Resolution: Completed Votes: 0
Labels: None

Affects Clojure from 1.2.0 to 1.3.0-alpha4

Approval: Ok


The code below defines a macro wrapper around defrecord. Using it causes a VerifyError:

(defmacro mac1 [name properties] 
  (let [key-info (keyword (first (filter #(meta %) properties)))] 
    (prn key-info) 
    `(defrecord ~name ~properties))) 

(mac1 One [^:key one, two])

Once this happens, the running Clojure process is oddly damaged. Changing the macro to a working version (see below) will not make the sample work with the tagged symbol, almost as if the symbol
'one (below) became corrupt. You either need to start a new REPL, or try to invoke the macro with a different tagged symbol.

The following code does work (note the forced conversion to a string):

(defmacro mac2 [name properties] 
  (let [key-info (keyword (str (first (filter #(meta %) properties))))] 
    (prn key-info) 
    `(defrecord ~name ~properties))) 

(mac2 Two [^:key three, four])

Comment by Rich Hickey [ 17/Dec/10 8:47 AM ]

Stu, can you please verify?

Comment by Stuart Halloway [ 17/Dec/10 1:53 PM ]

Very confusing. Reproduced everything in the report. Moreover, leaving out the call to keyword is enough to avoid the problem. The following variant works fine:

(defmacro mac4 [name properties] 
  (let [key-info (first (filter #(meta %) properties))] 
    (prn key-info) 
    `(defrecord ~name ~properties)))
Comment by Constantine Vetoshev [ 18/Dec/10 1:02 PM ]

Thanks for the fix! Works great.

Generated at Thu Jan 18 12:03:32 CST 2018 using JIRA 4.4#649-r158309.