ClojureScript

Need to reject incorrect fn with fixed arity of more params than variadic

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

ClojureScript 1.10.339
cljs.user=> (defn foo ([x] [:single x]) ([& xs] [:variadic xs]))
#'cljs.user/foo
cljs.user=> (foo 1)
[:single 1]
cljs.user=> (foo 1 2)
[:variadic 1]

Note that the variadic call provides the wrong answer.

It appears that the right thing to do is not "make it work" but to reject the code as incorrect. See Clojure:

user=> (defn foo ([x] [:single x]) ([& xs] [:variadic xs]))
CompilerException java.lang.RuntimeException: Can't have fixed arity function with more params than variadic function, compiling:(NO_SOURCE_PATH:1:1)

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: