deftype error message is misleading not useful

Description

If you forget to include the argument vector for deftype, i.e.

(deftype second-request-handler
HttpServer.RequestHandler
(canRespond [this request] true)
(getResponse [this request] nil))

which should be...

(deftype second-request-handler []
HttpServer.RequestHandler
(canRespond [this request] true)
(getResponse [this request] nil))

I get the error message..

Don't know how to create ISeq from: clojure.lang.Symbol (main.clj:1)

When in fact the error is coming from (second-request-handler.clj:3). Can this error message be improved and give the actually location of the error?

Environment

OS X

Attachments

2

Activity

Andy Fingerhut 
April 27, 2012 at 1:29 AM

clj-897-deftype-error-message-is-misleading-patch.txt dated Apr 26 2012 is the same as Tassilo Horn's patch, except it is updated to apply cleanly to latest master as of today.

Andy Fingerhut 
March 23, 2012 at 8:40 AM

Changing Patch attribute to "Code".

Tassilo Horn 
December 23, 2011 at 10:28 AM

The problem is that deftype and defrecord use destructuring in the argument vector, so the error pops up before the macro is actually running.

The attached patch removes the destructuring form (but keeps the nice syntax in :arglists) and adds a vector? check to validate-fields.

All tests pass, and the example above now errors with "AssertionError No fields vector given."

Completed

Details

Assignee

Reporter

Approval

Patch

Priority

Affects versions

Fix versions

Created December 14, 2011 at 2:46 PM
Updated June 15, 2012 at 5:09 PM
Resolved June 15, 2012 at 5:09 PM