Clojure

Incorrect ArityException message for function names containing ->

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.2, Release 1.3, Release 1.4, Release 1.5
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code
  • Approval:
    Incomplete

Description

user=> (defn a->b [])
#'user/a->b
user=> (a->b 1)
ArityException Wrong number of args (1) passed to: user$a clojure.lang.AFn.throwArity (AFn.java:437)

Note that the reported function name in the stack trace is "user$a", where it should be "user$a->b" (or some mangled variant thereof?)

See discussion here: https://groups.google.com/d/msg/clojure/PVNoLclhhB0/_NWqyE0cPAUJ

Activity

Stuart Halloway made changes -
Field Original Value New Value
Approval Vetted [ 10003 ]
Fix Version/s Approved Backlog [ 10034 ]
Hide
Timothy Baldridge added a comment -

Fix for this defect.

Show
Timothy Baldridge added a comment - Fix for this defect.
Timothy Baldridge made changes -
Attachment better-throw-arity-messages.diff [ 11710 ]
Hide
Timothy Baldridge added a comment -

The throwArity now attempts to locate and call clojure.main/demunge. If it finds the function it invokes it and uses the returned string in the error. Otherwise it just throws the actual class name. This results in the following behaviour:

user=> (defn a->b [])
#'user/a->b
user=> (a->b 32)
ArityException Wrong number of args (1) passed to: user/a->b clojure.lang.AFn.throwArity (AFn.java:449)
user=>

Show
Timothy Baldridge added a comment - The throwArity now attempts to locate and call clojure.main/demunge. If it finds the function it invokes it and uses the returned string in the error. Otherwise it just throws the actual class name. This results in the following behaviour: user=> (defn a->b []) #'user/a->b user=> (a->b 32) ArityException Wrong number of args (1) passed to: user/a->b clojure.lang.AFn.throwArity (AFn.java:449) user=>
Timothy Baldridge made changes -
Patch Code [ 10001 ]
Rich Hickey made changes -
Fix Version/s Approved Backlog [ 10034 ]
Fix Version/s Release 1.6 [ 10157 ]
Hide
Stuart Halloway added a comment -

Timothy: Why the empty catch block? I don't see anything in the try block whose failure we would want to ignore.

Show
Stuart Halloway added a comment - Timothy: Why the empty catch block? I don't see anything in the try block whose failure we would want to ignore.
Stuart Halloway made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated: