core: variadic bit ops, set? covers sorted sets, if rejects extra forms

Three canonical-conformance fixes from the post-shrink batch:

- bit-and/bit-or/bit-xor/bit-and-not get Clojure's variadic arities as
  20-coll shells folding the binary host ops (now __bit-* seams). 2-arg call
  sites still compile to the native janet op via the backend's native-ops
  table. The passes.clj constant-fold table now names the seams — the public
  fns are overlay and don't exist when the compiler loads (this briefly broke
  every compile-mode init).

- core-set? recognizes the :jolt/sorted-set representation (jolt-dpn):
  (set? (sorted-set 1)) was false, and ifn? on sorted sets inherited the bug.

- (if) / (if test) / (if test then else extra) throw in both the analyzer
  and the interpreter — spec 03-special-forms X1, now marked verified.

Suite 4704 -> 4706; bench and the greeter example benchmark are flat.
This commit is contained in:
Yogthos 2026-06-11 17:04:26 -04:00
parent 621dc8e310
commit c6f6b7deb7
9 changed files with 84 additions and 16 deletions

View file

@ -81,3 +81,12 @@
["call literal fn" "1" "((fn* [] 1))"]
["call nested" "6" "(+ ((fn* [] 1)) ((fn* [] 2)) ((fn* [] 3)))"]
["call nil" :throws "(nil)"])
# if takes two or three argument forms — anything else is a compile-time
# error (spec 03-special-forms X1).
(defspec "forms / if arity (X1)"
["bare if throws" :throws "(if)"]
["one-arg if throws" :throws "(if true)"]
["four-arg if throws" :throws "(if true 1 2 3)"]
["two-arg if ok" "nil" "(if false 1)"]
["three-arg if ok" "2" "(if false 1 2)"])

View file

@ -204,3 +204,17 @@
["== int and double" "true" "(== 1 1.0)"]
["== throws on non-number" :throws "(== 1 :a)"]
["== throws on two keywords" :throws "(== :a :a)"])
# Variadic bit ops (canonical Clojure arities: binary host op folded over the
# rest). Shift/clear/set/flip/test stay 2-arg, as in Clojure.
(defspec "numbers / variadic bit ops"
["bit-and 2" "4" "(bit-and 12 6)"]
["bit-and 3" "4" "(bit-and 12 6 7)"]
["bit-and 4" "0" "(bit-and 12 6 7 3)"]
["bit-or 3" "7" "(bit-or 1 2 4)"]
["bit-xor 3" "7" "(bit-xor 1 2 4)"]
["bit-xor folds left" "1" "(bit-xor 5 6 2)"]
["bit-and-not 2" "8" "(bit-and-not 12 6)"]
["bit-and-not 3" "8" "(bit-and-not 12 6 3)"]
["bit-and single arg throws" :throws "(bit-and 5)"]
["bit-or keeps binary fast path" "3" "(bit-or 1 2)"])

View file

@ -43,3 +43,16 @@
["join" "#{{:a 1, :b 2, :c 3}}" "(do (require (quote [clojure.set :as s])) (s/join #{{:a 1 :b 2}} #{{:b 2 :c 3}}))"]
["map-invert" "{1 :a}" "(do (require (quote [clojure.set :as s])) (s/map-invert {:a 1}))"]
["rename-keys" "{:b 1}" "(do (require (quote [clojure.set :as s])) (s/rename-keys {:a 1} {:a :b}))"])
# set? recognizes every set representation (jolt-dpn: sorted sets are tagged
# tables the host set? predicate missed).
(defspec "set / set? across representations"
["literal" "true" "(set? #{1})"]
["empty literal" "true" "(set? #{})"]
["sorted-set" "true" "(set? (sorted-set 1 2))"]
["sorted-set-by" "true" "(set? (sorted-set-by > 1 2))"]
["empty sorted" "true" "(set? (sorted-set))"]
["map is not" "false" "(set? {})"]
["vector is not" "false" "(set? [1])"]
["coll? still true" "true" "(coll? (sorted-set 1))"]
["ifn? sorted-set" "true" "(ifn? (sorted-set 1))"])