Fork me on GitHub

Out of curiosity, how much work would it be to get a better error message for this:


10:07 $ clj
Clojure 1.10.0
user=> (defn foo [{:key [lol]}] )
Syntax error macroexpanding clojure.core/defn at (REPL:1:1).
{:key [lol]} - failed: vector? at: [:fn-tail :arity-n :bodies :params] spec: :clojure.core.specs.alpha/param-list
({:key [lol]}) - failed: Extra input at: [:fn-tail :arity-1 :params] spec: :clojure.core.specs.alpha/param-list


I would have expected something that told me that :key was not a valid destructuring thing.


@slipset Interesting. I think you can already experiment with this yourself, by overriding the specs here in your REPL:


I did. For five minutes. Then returned to work 🙂

Alex Miller (Clojure team)13:02:29

In short, not easily - the keys of the destructuring map are symbols, vectors, or a set of different known or open key sets

Alex Miller (Clojure team)13:02:16

Maybe it would be possible to write a predicate and then s/merge a map spec that narrowed the keys to that. I’ve messed with all that a bit, never got happy with it


Speaking about core specs: I’ve seen this error more than once.


Not really a question. More an observation that these specs forbid something that used to work before and occurred in people’s code.

Alex Miller (Clojure team)14:02:53

that has never worked. before it just silently had no effect, now it tells you.


ah right! in this case the import wasn’t even needed: that set me on the wrong foot 🙂

Alex Miller (Clojure team)14:02:52

that is true of literally 100% of these (because they previously had no effect)


Hail the spec!


would there be any interest to extend the integer regex to allow for an l suffix to require Long in the same way you can add an N to require a BigInt? Not often used but coworker was surprised by the type promotion to BigInteger


seems to align with known jvm syntax but also dangerously close to the "who would ever use this" line? Just wondering

Alex Miller (Clojure team)23:02:25

What problem are you trying to solve?


i think it was more flashbacks from silent type promotion in php. We were reading the source after a discussion in #beginners and he was surprised that he couldn't guarantee the return type of the literal. IE, all theoretical and no actual problem at hand

Alex Miller (Clojure team)23:02:44

That sounds like a pretty weak problem statement :)


i agree 🙂


Any objections to adding @zulip-mirror-bot to this channel to mirror messages to Clojurians on Zulip > slack-archive stream > clojure-dev topic?


(mostly I've just been adding it to channels here but I figured I'd ask for this channel)


Mind you, @logbot is already so I guess it's about the same thing. I'll add it. If anyone objects, I can remove it again 🙂