Chez parity: trailing-apostrophe symbols + arglist return hints (jolt-vgrp, jolt-5540)

Two Chez reader bugs, both JVM-parity gaps:

inc'/+'/foo' (trailing apostrophe) were mis-read as a symbol followed by a
quote macro, because the reader treated ' as a terminator. In Clojure ' is a
NON-terminating macro char (constituent after the first char). Since the seed
is minted on Chez, (def inc' inc) became (def inc 'inc), clobbering inc's var
cell with its own symbol -- so (var-get (var inc)) returned the symbol, not the
fn. Drop ' from the token terminator set; a leading ' still quotes.

^bytes [b] / ^String [x y] return-type hints: the Chez reader lowered ^meta on
a collection to a (with-meta vec meta) form, but emitted a QUALIFIED
clojure.core/with-meta while the Janet reader emits a bare with-meta -- so the
fn/defn macros' unwrap logic (matching the bare head) slipped past it and choked
on a non-vector arglist. Emit bare with-meta to match Janet, and unwrap a
(with-meta <vec> _) arglist in analyze-fn as a backstop.

Re-minted the seed. zero-janet 2699, prelude 2652, Janet gate 155/0, fixpoint
10/10, bootstrap 6/6, all 0 new divergences.
This commit is contained in:
Yogthos 2026-06-20 22:17:29 -04:00
parent 53a189541c
commit eb1c3298a4
5 changed files with 53 additions and 25 deletions

View file

@ -136,11 +136,28 @@
;; but keeps a fixed arity a nil-free struct rather than a phm.
(if rst (assoc arity :rest rst) arity)))
;; A reader that lowers ^meta on a collection to a runtime (with-meta <coll> <meta>)
;; form (the Chez data reader) wraps an arglist vector carrying a return-type hint
;; (^bytes [b] / ^String [x y]). Unwrap to the underlying vector so fn parsing sees
;; the params — the hint is ignored at runtime. Only the (with-meta <vec> _) shape
;; matches, so a real arity clause (head is a vector) and the Janet reader's
;; meta-on-tuple (already a vector) pass through unchanged.
(defn- strip-arglist-meta [form]
(if (form-list? form)
(let [es (vec (form-elements form))]
(if (and (= 3 (count es))
(form-sym? (first es))
(= "with-meta" (form-sym-name (first es)))
(form-vec? (nth es 1)))
(nth es 1)
form))
form))
(defn- analyze-fn [ctx items env]
(let [named (form-sym? (nth items 1))
fn-name (when named (form-sym-name (nth items 1)))
rest-items (if named (drop 2 items) (drop 1 items))
first* (first rest-items)]
first* (strip-arglist-meta (first rest-items))]
(cond
(form-vec? first*)
(fn-node fn-name [(analyze-arity ctx first* (rest rest-items) env fn-name)])
@ -148,7 +165,7 @@
(fn-node fn-name
(mapv (fn [clause]
(let [cl (vec (form-elements clause))]
(analyze-arity ctx (first cl) (rest cl) env fn-name)))
(analyze-arity ctx (strip-arglist-meta (first cl)) (rest cl) env fn-name)))
rest-items))
:else (uncompilable "fn: bad params"))))