core: staged recompile for early defns; keys/vals/empty? leave the seed (jolt-4j3)
recompile-defns! is the defn analog of recompile-macros!: pre/at-kernel
overlay defns (00-syntax's destructure and friends; the kernel tier too in
interpret mode) load as interpreted closures, the evaluator stashes their fn
source on the var (:defn-src, scoped by a flag only api/load-core-overlay!
sets), and the end-of-init pass compiles them and swaps the var root. With
that in place, keys/vals/empty? — the fns the 00-syntax expanders call at
expansion time — move to the top of 00-syntax as raw fn* defs (canonical:
keys/vals project (seq m), so sorted maps come back in comparator order and
(keys {}) is nil; empty? keeps O(1) count dispatch with seq's cell check only
for the lazy/list fallback). The sorted tier drops its now-dead :keys/:vals
ops.
Correctness fixes that surfaced once the gate was run with a REAL exit code
(the previous 'jpm test | grep' gates reported grep's exit and masked spec
failures across #48-#50):
- map conj is strict again: a non-nil/non-map arg must be a 2-element vector
('Vector arg to map conj must be a pair'), and merge inherits it — the
batch-2 canonical merge had silently dropped the validation
- conj onto a lazy seq prepends (it fell into the MAP fallback); upstream
clojure.data/diff relies on (conj seq x) via set/union over keys, so diff
now matches Clojure exactly
- (seq {}) / (seq #{}) / empty phm are nil, not ()
- key/val are strict (a plain vector is not an entry); find mints a REAL
entry as the first entry of a one-entry map, nil values intact
- the sci avoid-method-too-large stub passes its registry map through
instead of returning a raw host table (strict conj rejected it; sci's
clojure-core registry is also no longer discarded)
Test updates: lazy-infinite pins take-nth realization at 5 (was 7 — the
canonical lazy impl realizes fewer); self-host asserts the analyzer IS loaded
in interpret mode (compiled expanders, PR #50) and is NOT in the
:compile-macros? false oracle. 18 new maps-spec rows.
Gate: jpm test exit 0 (verified directly, not through a pipe), conformance
326x3, suite 4698 >= 4660.
This commit is contained in:
parent
e6f562c175
commit
63eb6eca6e
11 changed files with 176 additions and 50 deletions
|
|
@ -70,9 +70,17 @@
|
|||
# Proof the self-hosted pipeline actually ran: only backend/ensure-analyzer
|
||||
# populates jolt.analyzer. An interpret-only ctx never loads it.
|
||||
(assert (pos? (length ((ctx-find-ns ctx "jolt.analyzer") :mappings))) "analyzer loaded under :compile?"))
|
||||
# Interpret mode now loads the analyzer too — for compiled macro expansion
|
||||
# (ensure-macros-compiled!, every mode). The fully-interpreted oracle is the
|
||||
# :compile-macros? false ctx, which must never touch the analyzer.
|
||||
(let [ctx (init-cached {})]
|
||||
(eval-one ctx (parse-string "(+ 1 2)"))
|
||||
(assert (zero? (length ((ctx-find-ns ctx "jolt.analyzer") :mappings))) "analyzer NOT loaded when interpreting"))
|
||||
(assert (pos? (length ((ctx-find-ns ctx "jolt.analyzer") :mappings)))
|
||||
"analyzer loaded when interpreting (compiled expanders)"))
|
||||
(let [ctx (init-cached {:compile-macros? false})]
|
||||
(eval-one ctx (parse-string "(+ 1 2)"))
|
||||
(assert (zero? (length ((ctx-find-ns ctx "jolt.analyzer") :mappings)))
|
||||
"analyzer NOT loaded in the interpreted-macro oracle"))
|
||||
|
||||
# clojure.core overlay: fns moved from core.janet to jolt-core/clojure/core.clj
|
||||
# load into clojure.core at init and work the same compiled or interpreted.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue