Clojure

different arrities of macro don't work in 1.2 (20100607 build)

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Declined
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

I've been in the process of upgrading my framework from 1.1 to 1.2 and I've hit a serious stopper in code that works (and was tested) under 1.1.

~/clojure-workspace/cascade
$ lein repl
cascade.version=> (use 'cascade)
nil
cascade.version=> (link nil nil nil)
java.lang.IllegalArgumentException: Wrong number of args (3) passed to: cascade$link (NO_SOURCE_FILE:1)
cascade.version=> (doc link)
-------------------------
cascade/link
([env function] [env function extra-path-info] [env function extra-path-info query-parameters])
Macro
  Creates a link to a view or action function. Additional path info data may be specified (as a seq of
  data items), as well as query parameters (as a map whose keys are strings or keywords and whose values
  are converted to strings.). Uses standard keys from the env map. The resulting link is returned as a string.
nil
cascade.version=> (.printStackTrace *e)
java.lang.IllegalArgumentException: Wrong number of args (3) passed to: cascade$link (NO_SOURCE_FILE:1)
 at clojure.lang.Compiler.eval(Compiler.java:5437)
 at clojure.lang.Compiler.eval(Compiler.java:5388)
 at clojure.core$eval.invoke(core.clj:2370)
 at clojure.main$repl$read_eval_print__5620.invoke(main.clj:183)
 at clojure.main$repl$fn__5625.invoke(main.clj:203)
 at clojure.main$repl.doInvoke(main.clj:203)
 at clojure.lang.RestFn.invoke(RestFn.java:422)
 at user$eval9$fn__10.invoke(NO_SOURCE_FILE:1)
 at user$eval9.invoke(NO_SOURCE_FILE:1)
 at clojure.lang.Compiler.eval(Compiler.java:5421)
 at clojure.lang.Compiler.eval(Compiler.java:5412)
 at clojure.lang.Compiler.eval(Compiler.java:5412)
 at clojure.lang.Compiler.eval(Compiler.java:5388)
 at clojure.core$eval.invoke(core.clj:2370)
 at clojure.main$eval_opt.invoke(main.clj:234)
 at clojure.main$initialize.invoke(main.clj:253)
 at clojure.main$null_opt.invoke(main.clj:278)
 at clojure.main$main.doInvoke(main.clj:353)
 at clojure.lang.RestFn.invoke(RestFn.java:422)
 at clojure.lang.Var.invoke(Var.java:369)
 at clojure.lang.AFn.applyToHelper(AFn.java:165)
 at clojure.lang.Var.applyTo(Var.java:482)
 at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: Wrong number of args (3) passed to: cascade$link
 at clojure.lang.AFn.throwArity(AFn.java:439)
 at clojure.lang.AFn.invoke(AFn.java:47)
 at cascade$link.invoke(cascade.clj:90)
 at cascade$link.invoke(cascade.clj:92)
 at clojure.lang.Var.invoke(Var.java:381)
 at clojure.lang.AFn.applyToHelper(AFn.java:180)
 at clojure.lang.Var.applyTo(Var.java:482)
 at clojure.lang.Compiler.macroexpand1(Compiler.java:5283)
 at clojure.lang.Compiler.macroexpand(Compiler.java:5338)
 at clojure.lang.Compiler.eval(Compiler.java:5406)
 ... 22 more
Reflection warning, NO_SOURCE_PATH:6 - reference to field printStackTrace can't be resolved.
nil
cascade.version=> 
</code></pre>
 

Here's the source:

<pre><code>
(defmacro link
  "Creates a link to a view or action function. Additional path info data may be specified (as a seq of
  data items), as well as query parameters (as a map whose keys are strings or keywords and whose values
  are converted to strings.). Uses standard keys from the env map. The resulting link is returned as a string."
  ([env function]
    (link env function nil))
  ([env function extra-path-info]
    (link env function extra-path-info nil))
  ([env function extra-path-info query-parameters]
    `(link-path ~env (link-map-from-function ~function ~extra-path-info ~query-parameters))))

So, (doc) shows the number of parameters correctly, as does the code, but attempting to use it with 3 parameters generates the spurious error.

Here's a simpler example:

<pre>
<code>
$ lein repl
cascade.version=> (defmacro ex ([a] (ex a "no-b")) ([a b] `(format "a=%s, b=%s" ~a ~b)))
#'cascade.version/ex
cascade.version=> (ex)
java.lang.IllegalArgumentException: Wrong number of args (2) passed to: version$ex (NO_SOURCE_FILE:1)
cascade.version=> (ex 1)
java.lang.IllegalArgumentException: Wrong number of args (2) passed to: version$ex (NO_SOURCE_FILE:1)
cascade.version=> (ex 1 2)
"a=1, b=2"
cascade.version=>
</code>
</pre>

Activity

People

  • Assignee:
    Unassigned
    Reporter:
    Anonymous
Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: