Clojure

deftype error message is misleading not useful

Details

  • Type: Enhancement Enhancement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: Release 1.3
  • Fix Version/s: Release 1.5
  • Component/s: None
  • Labels:
    None
  • Environment:
    OS X
  • Patch:
    Code
  • Approval:
    Ok

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?

Activity

Hide
Tassilo Horn added a comment -

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."

Show
Tassilo Horn added a comment - 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."
Hide
Andy Fingerhut added a comment -

Changing Patch attribute to "Code".

Show
Andy Fingerhut added a comment - Changing Patch attribute to "Code".
Hide
Andy Fingerhut added a comment -

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.

Show
Andy Fingerhut added a comment - 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.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: