<< Back to previous view

[CLJS-627] Need to enforce "Can't have fixed arity function with more params than variadic function" Created: 18/Oct/13  Updated: 04/Nov/13  Resolved: 04/Nov/13

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: George Fraser Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: File cljs-627-20131104-2.diff     File cljs-627-20131104.diff     File fixed-arity-20131021.diff    


In Clojure:

> (defn f
([a] :one])
([& many] :many))
CompilerException...Can't have fixed arity function with more params than variadic function

In ClojureScript:
> (defn f
([a] :one])
([& many] :many))
[ succeeds ]
> (f 1)
> (f 1 2)

ClojureScript should throw an error like Clojure.

Comment by Travis Thieman [ 21/Oct/13 10:01 AM ]

Patch: 20131021. Work in progress.

Throw in the analyzer when multiple variadic methods are defined for a single function, or when a fixed arity function has more parameters than a variadic function. These should be replaced by warnings once the warning system is reworked, see CLJS-622.

Comment by David Nolen [ 28/Oct/13 8:50 AM ]

CLJS-636 must be resolved first.

Comment by David Nolen [ 04/Nov/13 8:22 AM ]

CLJS-636 is resolved can we get an updated patch?

Comment by Travis Thieman [ 04/Nov/13 1:18 PM ]

Patch: 20131104

Adds three warning types having to do with function arity.

Comment by David Nolen [ 04/Nov/13 1:22 PM ]

It's important to check that a particular warning isn't being explicitly suppressed, otherwise you'll get really annoying warning duplication in the case of a) multiple passes from the compiler, b) the two analysis runs on the form used by REPLs.

Comment by Travis Thieman [ 04/Nov/13 3:58 PM ]

Patch: 20131104-2

Revised to not throw warnings when explicitly silenced in cljs-warnings

Comment by David Nolen [ 04/Nov/13 8:18 PM ]

fixed, https://github.com/clojure/clojurescript/commit/55ee7fd58c23ff2c2950fdf3357257b71e967edf

Generated at Tue Oct 24 06:30:44 CDT 2017 using JIRA 4.4#649-r158309.