Clojure

Bindings after :as in list destructuring should throw error

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: Release 1.4, Release 1.5
  • Fix Version/s: None
  • Component/s: None

Description

If you try to define a vector binding with anything at all after an :as parameter, you do not get a compiler error, and the binding is silently swallowed:

user> ((fn [[:as y z]] y) [1 2])
[1 2]

If you try to actually use the binding, there will be a compiler error (the compiler will complain that there's no binding for the symbol), but the actual error has already happened, and should be reported earlier.

Activity

Alex Miller made changes -
Field Original Value New Value
Labels Compiler bug Compiler errormsgs
Alex Miller made changes -
Description If you try to define a vector binding with a non-as parameter after a rest parameter, you get a compiler error:

user> (fn [[& z y]] z)
CompilerException java.lang.Exception: Unsupported binding form, only :as can follow & parameter, compiling:(NO_SOURCE_PATH:1)

But if you try to define a vector binding with anything at all after an as parameter, you do not get a compiler error, and the binding is silently swallowed:

user> ((fn [[:as y z]] y) [1 2])
[1 2]

If you try to actually use the binding, there will be a compiler error (the compiler will complain that there's no binding for the symbol), but the actual error has already happened, and should be reported earlier.
If you try to define a vector binding with anything at all after an :as parameter, you do not get a compiler error, and the binding is silently swallowed:

{code}
user> ((fn [[:as y z]] y) [1 2])
[1 2]
{code}

If you try to actually use the binding, there will be a compiler error (the compiler will complain that there's no binding for the symbol), but the actual error has already happened, and should be reported earlier.
Summary bindings after :as-bindings in vectors should be compiler errors Bindings after :as in list destructuring should throw error
Alex Miller made changes -
Issue Type Defect [ 1 ] Enhancement [ 4 ]

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: