Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
For parity with Clojure, add runtime checks in map {{conj}} implementations such that vector arguments must be pairs.

Clojure:


user=> (conj {:a 1} [:b 2 2])
Execution error (IllegalArgumentException) at user/eval7 (REPL:1).
Vector arg to map conj must be a pair
user=> (conj {:a 1} [:b])
Execution error (IllegalArgumentException) at user/eval9 (REPL:1).
Vector arg to map conj must be a pair
user=> (conj {:a 1} [])
Execution error (IllegalArgumentException) at user/eval11 (REPL:1).
Vector arg to map conj must be a pair


ClojureScript:


cljs.user=> (conj {:a 1} [:b 2 2])
{:a 1, :b 2}
cljs.user=> (conj {:a 1} [:b])
Execution error (Error) at (<cljs repl>:1).
No item 1 in vector of length 1

cljs.user=> (conj {:a 1} [])
Execution error (Error) at (<cljs repl>:1).
No item 0 in vector of length 0


Rationale: Even though this would reject some programs, those programs are incorrect and non-portable to Clojure.

1 Answer

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-3111 (reported by mfikes)
...