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

Hide
Timothy Baldridge added a comment -

Fix for this defect.

Show
Timothy Baldridge added a comment - Fix for this defect.
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=>
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.

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated: