Chez Phase 1 (increment 3c): multi-arity + variadic fn emission

emit-fn lowered multi-arity fns to a Scheme case-lambda and variadic fns to
a rest-arg lambda; the Scheme rest list is coerced to a jolt seq (nil when
empty, via list->cseq), and the named-let wrapper runs that coercion only on
first entry so recur carries the seq directly. Single fixed arity keeps the
plain-lambda fast path (fib untouched).

Also fixes a latent leak in the module-global known-procs: a throw mid-emit
(uncompilable body) left the fn's name registered, so a later corpus case
binding the same name to a keyword emitted a direct call to a non-procedure.
The cleanup now runs on the error path too. Only surfaced once the new arity
support let +24 cases compile further before hitting an uncompilable fn.

Gate: emit-test 81/81, subset probe 619/619 compiled (was 595), 0 divergences,
2036/2655 out of subset; full run-tests green (125 files).
This commit is contained in:
Yogthos 2026-06-17 16:08:27 -04:00
parent cb3cfaf0c2
commit 45208afff1
3 changed files with 78 additions and 20 deletions

View file

@ -48,13 +48,19 @@ compile-time signal) and are counted "out of subset", not as divergences.
JOLT_CHEZ_CORPUS=1 janet test/chez/run-corpus-chez.janet
Baseline after inc 3b (seq tier + dynamic IFn, jolt-5pso): **595/595 compiled
cases pass**, 0 divergences; 2060/2655 out of subset (await clojure.core on Chez).
The seq tier brought up a list/lazy-seq type with first/rest/next/seq/cons/list,
map/filter/reduce/into/remove, range/take/drop/concat/apply, keys/vals, and
nth/peek/pop over seqs; dynamic IFn dispatch (a keyword/vector/coll held in a
local and called as a fn) now routes through the `jolt-invoke` fallback, closing
the 3 ex-known divergences. The probe exits non-zero on any NEW divergence.
Baseline after inc 3c (multi-arity + variadic fns, jolt-gret): **619/619 compiled
cases pass**, 0 divergences; 2036/2655 out of subset (await clojure.core on Chez).
`emit-fn` now lowers multi-arity fns to a Scheme `case-lambda` and variadic fns to
a rest-arg lambda (the Scheme rest list is coerced to a jolt seq, nil when empty),
which is the gating lift for emitting the clojure.core tiers as a prelude.
Prior, inc 3b (seq tier + dynamic IFn, jolt-5pso): 595/595 compiled, 0 divergences,
2060/2655 out of subset. The seq tier brought up a list/lazy-seq type with
first/rest/next/seq/cons/list, map/filter/reduce/into/remove,
range/take/drop/concat/apply, keys/vals, and nth/peek/pop over seqs; dynamic IFn
dispatch (a keyword/vector/coll held in a local and called as a fn) routes through
the `jolt-invoke` fallback, closing the 3 ex-known divergences. The probe exits
non-zero on any NEW divergence.
(Prior, inc 3a: 433/436 compiled, 3 known IFn divergences, 2219 out of subset.
Inc 2: 182/182 compiled, 0 divergences, 2473 out of subset.)