ClojureScript

Need to enforce "Can't have fixed arity function with more params than variadic function"

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

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)
:many
> (f 1 2)
:many

ClojureScript should throw an error like Clojure.

  1. cljs-627-20131104.diff
    04/Nov/13 1:18 PM
    3 kB
    Travis Thieman
  2. cljs-627-20131104-2.diff
    04/Nov/13 3:58 PM
    3 kB
    Travis Thieman
  3. fixed-arity-20131021.diff
    21/Oct/13 10:01 AM
    2 kB
    Travis Thieman

Activity

Hide
Travis Thieman added a comment -

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.

Show
Travis Thieman added a comment - 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.
Travis Thieman made changes -
Field Original Value New Value
Attachment fixed-arity-20131021.diff [ 12348 ]
Hide
David Nolen added a comment -

CLJS-636 must be resolved first.

Show
David Nolen added a comment - CLJS-636 must be resolved first.
Hide
David Nolen added a comment -

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

Show
David Nolen added a comment - CLJS-636 is resolved can we get an updated patch?
Hide
Travis Thieman added a comment -

Patch: 20131104

Adds three warning types having to do with function arity.

Show
Travis Thieman added a comment - Patch: 20131104 Adds three warning types having to do with function arity.
Travis Thieman made changes -
Attachment cljs-627-20131104.diff [ 12431 ]
Hide
David Nolen added a comment -

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.

Show
David Nolen added a comment - 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.
Hide
Travis Thieman added a comment -

Patch: 20131104-2

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

Show
Travis Thieman added a comment - Patch: 20131104-2 Revised to not throw warnings when explicitly silenced in cljs-warnings
Travis Thieman made changes -
Attachment cljs-627-20131104-2.diff [ 12433 ]
David Nolen made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
David Nolen made changes -
Status Resolved [ 5 ] Closed [ 6 ]

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: