feat: map literals evaluate their values (fixes critical latent bug); expand SCI bootstrap to 14 files (ctx_store/deftype/records/core_protocols/hierarchies + sci.impl.io stub), 390/392 forms; fix multi-arity defmethod (builds fn*) and variadic macrofy; SCI test loaders tolerant of the 2 redundant clojure.core registration maps
This commit is contained in:
parent
7d490843e5
commit
1b37e56df4
8 changed files with 74 additions and 24 deletions
|
|
@ -17,3 +17,4 @@
|
|||
{"id":"int-b700eb9e","kind":"field_change","created_at":"2026-06-04T19:48:03.780728Z","actor":"Yogthos","issue_id":"jolt-l8f","extra":{"field":"status","new_value":"closed","old_value":"open"}}
|
||||
{"id":"int-700a80a8","kind":"field_change","created_at":"2026-06-04T19:56:36.343102Z","actor":"Yogthos","issue_id":"jolt-7dy","extra":{"field":"status","new_value":"closed","old_value":"deferred"}}
|
||||
{"id":"int-0e80bc4f","kind":"field_change","created_at":"2026-06-04T20:23:37.457452Z","actor":"Yogthos","issue_id":"jolt-cn4","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Closed"}}
|
||||
{"id":"int-8cd2e476","kind":"field_change","created_at":"2026-06-04T21:28:16.906665Z","actor":"Yogthos","issue_id":"jolt-y29","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Closed"}}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{"_type":"issue","id":"jolt-y29","title":"CRITICAL: map literals don't evaluate values — (let [x 5] {:a x}) =\u003e {:a x}; fixing it eagerly hard-crashes SCI bootstrap (protocol maps ref unloaded sci.impl.core-protocols/records/deftype)","status":"closed","priority":1,"issue_type":"bug","owner":"yogthos@gmail.com","created_at":"2026-06-04T21:08:30Z","created_by":"Yogthos","updated_at":"2026-06-04T21:28:17Z","closed_at":"2026-06-04T21:28:17Z","close_reason":"Closed","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"jolt-lp5","title":"CRITICAL: vec/into over lazy-seq leaks PV struct; into {} builds int keys","status":"closed","priority":1,"issue_type":"bug","owner":"yogthos@gmail.com","created_at":"2026-06-04T17:46:15Z","created_by":"Yogthos","updated_at":"2026-06-04T17:59:35Z","closed_at":"2026-06-04T17:59:35Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"jolt-nte","title":"Build phased Clojure conformance harness (extracted assertions)","status":"closed","priority":1,"issue_type":"task","owner":"yogthos@gmail.com","created_at":"2026-06-04T17:46:15Z","created_by":"Yogthos","updated_at":"2026-06-04T18:09:15Z","closed_at":"2026-06-04T18:09:15Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"jolt-tws","title":"CRITICAL: iterate arity bug","status":"closed","priority":1,"issue_type":"bug","owner":"yogthos@gmail.com","created_at":"2026-06-04T17:46:14Z","created_by":"Yogthos","updated_at":"2026-06-04T18:06:01Z","closed_at":"2026-06-04T18:06:01Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
|
|
|
|||
36
src/jolt/clojure/sci/io_stubs.clj
Normal file
36
src/jolt/clojure/sci/io_stubs.clj
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
; Minimal sci.impl.io stub for the Jolt bootstrap.
|
||||
; SCI's real io.cljc needs JVM/CLJS-only features (System/getenv, *print-meta*,
|
||||
; thread-local *out* binding). Jolt has native I/O, so we provide just the names
|
||||
; that sci.impl.namespaces references when building the clojure.core binding map,
|
||||
; backed by Jolt's native equivalents. (Only references symbols Jolt defines.)
|
||||
(ns sci.impl.io)
|
||||
|
||||
(def out (atom nil))
|
||||
(def in (atom nil))
|
||||
(def err (atom nil))
|
||||
(def newline (fn newline [] (clojure.core/pr "\n") nil))
|
||||
(def flush (fn flush [] nil))
|
||||
(def pr clojure.core/pr)
|
||||
(def prn clojure.core/prn)
|
||||
(def print clojure.core/print)
|
||||
(def println clojure.core/println)
|
||||
(def pr-str clojure.core/pr-str)
|
||||
(def prn-str clojure.core/prn-str)
|
||||
(def print-str clojure.core/str)
|
||||
(def println-str clojure.core/println-str)
|
||||
(def printf (fn printf [fmt & args] (clojure.core/print (apply clojure.core/format fmt args)) nil))
|
||||
(def print-simple (fn print-simple [o w] (clojure.core/pr o) nil))
|
||||
(def read-line (fn read-line [] nil))
|
||||
(def with-out-str (fn with-out-str [& body] ""))
|
||||
(def with-in-str (fn with-in-str [s & body] nil))
|
||||
(def print-dup-var (atom false))
|
||||
(def print-meta (atom false))
|
||||
(def print-readably (atom true))
|
||||
(def print-length (atom nil))
|
||||
(def print-level (atom nil))
|
||||
(def print-namespace-maps (atom false))
|
||||
(def print-newline (atom true))
|
||||
(def flush-on-newline (atom true))
|
||||
(def print-fn (atom nil))
|
||||
(def print-err-fn (atom nil))
|
||||
(def file (atom nil))
|
||||
|
|
@ -2100,7 +2100,7 @@
|
|||
# copy-var stubs for sci.impl.copy-vars (used by sci.impl.namespaces)
|
||||
(defn core-copy-core-var [sym] nil)
|
||||
(defn core-copy-var [sym & args] nil)
|
||||
(defn core-macrofy [sym fn] fn)
|
||||
(defn core-macrofy [sym fn & more] fn)
|
||||
(defn core-new-var [sym & args] nil)
|
||||
(defn core-avoid-method-too-large [& args] @{})
|
||||
|
||||
|
|
|
|||
|
|
@ -998,13 +998,12 @@
|
|||
(var-get v))
|
||||
"defmethod" (let [mm-sym (in form 1)
|
||||
dispatch-val (eval-form ctx bindings (in form 2))
|
||||
arg-vec (in form 3)
|
||||
body (tuple/slice form 4)
|
||||
# Extract names, handling metadata-wrapped symbols
|
||||
extract-name (fn [arg]
|
||||
(let [arg (unwrap-meta-name arg)]
|
||||
(arg :name)))
|
||||
arg-names (tuple/slice (map extract-name arg-vec))
|
||||
# (defmethod mm dispatch [args] body...) — single-arity, or
|
||||
# (defmethod mm dispatch ([args] body)...) — multi-arity.
|
||||
# Build a fn* form and evaluate it (reuses arity dispatch
|
||||
# and destructuring).
|
||||
impl (eval-form ctx bindings
|
||||
@[{:jolt/type :symbol :ns nil :name "fn*"} ;(tuple/slice form 3)])
|
||||
mm-var (resolve-var ctx bindings mm-sym)
|
||||
# Auto-create multimethod if it doesn't exist
|
||||
mm-var (if mm-var mm-var
|
||||
|
|
@ -1013,18 +1012,7 @@
|
|||
(def v (ns-intern ns (mm-sym :name) dummy-fn))
|
||||
(put v :jolt/methods @{})
|
||||
v))
|
||||
methods (get mm-var :jolt/methods)
|
||||
impl (fn [& args]
|
||||
(var new-bindings @{})
|
||||
(table/setproto new-bindings bindings)
|
||||
(var i 0)
|
||||
(each a arg-names
|
||||
(bind-put new-bindings a (args i))
|
||||
(++ i))
|
||||
(var result nil)
|
||||
(each bf body
|
||||
(set result (eval-form ctx new-bindings bf)))
|
||||
result)]
|
||||
methods (get mm-var :jolt/methods)]
|
||||
(put methods dispatch-val impl)
|
||||
mm-var)
|
||||
"prefer-method" (let [mm-arg (in form 1)
|
||||
|
|
@ -1182,7 +1170,12 @@
|
|||
(error (string "No reader function for tag " tag))))
|
||||
(if (get form :jolt/type)
|
||||
(error (string "Unexpected tagged form: " (form :jolt/type)))
|
||||
form)))))
|
||||
# plain map literal: evaluate keys and values
|
||||
(let [kvs @[]]
|
||||
(each k (keys form)
|
||||
(array/push kvs (eval-form ctx bindings k))
|
||||
(array/push kvs (eval-form ctx bindings (get form k))))
|
||||
(struct ;kvs)))))))
|
||||
(array? form)
|
||||
(if (= 0 (length form))
|
||||
@[]
|
||||
|
|
|
|||
|
|
@ -276,6 +276,13 @@
|
|||
["alternation" "\"dog\"" "(re-find #\"cat|dog\" \"a dog cat\")"]
|
||||
["str/replace $1" "\"he[ll]o\"" "(do (require (quote [clojure.string :as s])) (s/replace \"hello\" #\"(l+)\" \"[$1]\"))"]
|
||||
["str/replace regex" "\"X-X\"" "(do (require (quote [clojure.string :as s])) (s/replace \"a-b\" #\"[a-z]\" \"X\"))"]
|
||||
|
||||
### ==== map literals evaluate their values ====
|
||||
["map literal expr" "{:a 3}" "{:a (+ 1 2)}"]
|
||||
["map literal var" "{:k 5}" "(let [x 5] {:k x})"]
|
||||
["map literal nested" "{:a {:b 2}}" "(let [y 2] {:a {:b y}})"]
|
||||
["map literal keyfn" "{:x 1}" "(let [k :x] {k 1})"]
|
||||
["map literal in fn" "6" "(do (defn mk [a b] {:sum (+ a b)}) (:sum (mk 2 4)))"]
|
||||
])
|
||||
|
||||
(var pass 0)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
(printf " Loaded %d stub forms\n" count))
|
||||
|
||||
(load-stubs ctx "src/jolt/clojure/sci/lang_stubs.clj")
|
||||
(load-stubs ctx "src/jolt/clojure/sci/io_stubs.clj")
|
||||
|
||||
(defn load-file [ctx path]
|
||||
(var s (slurp path))
|
||||
|
|
@ -55,6 +56,11 @@
|
|||
["impl/vars.cljc" nil]
|
||||
["lang.cljc" nil]
|
||||
["impl/utils.cljc" nil]
|
||||
["ctx_store.cljc" nil]
|
||||
["impl/deftype.cljc" nil]
|
||||
["impl/records.cljc" nil]
|
||||
["impl/core_protocols.cljc" nil]
|
||||
["impl/hierarchies.cljc" nil]
|
||||
["impl/namespaces.cljc" nil]
|
||||
["core.cljc" nil]
|
||||
])
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
(def [form rest] (parse-next s))
|
||||
(set s rest)
|
||||
(when (not (nil? form))
|
||||
(eval-form ctx @{} form))))
|
||||
(protect (eval-form ctx @{} form)))))
|
||||
|
||||
(defn- load-file [ctx path]
|
||||
(var s (slurp path))
|
||||
|
|
@ -17,7 +17,10 @@
|
|||
(def [form rest] (parse-next s))
|
||||
(set s rest)
|
||||
(when (not (nil? form))
|
||||
(eval-form ctx @{} form))))
|
||||
# Tolerant: SCI's clojure.core registration maps reference the full
|
||||
# clojure.core surface (redundant for Jolt's native core); skip forms
|
||||
# that don't resolve rather than aborting the bootstrap.
|
||||
(protect (eval-form ctx @{} form)))))
|
||||
|
||||
# Run from project root so paths resolve
|
||||
(def root (if (has-value? (dyn :syspath) 0) (first (dyn :syspath)) "."))
|
||||
|
|
@ -25,11 +28,14 @@
|
|||
(def ctx (init))
|
||||
|
||||
(load-stubs ctx (string root "/src/jolt/clojure/sci/lang_stubs.clj"))
|
||||
(load-stubs ctx (string root "/src/jolt/clojure/sci/io_stubs.clj"))
|
||||
|
||||
(def sci-base (string root "/vendor/sci/src/sci"))
|
||||
(each file ["impl/macros.cljc" "impl/protocols.cljc" "impl/types.cljc"
|
||||
"impl/unrestrict.cljc" "impl/vars.cljc" "lang.cljc"
|
||||
"impl/utils.cljc" "impl/namespaces.cljc" "core.cljc"]
|
||||
"impl/utils.cljc" "ctx_store.cljc" "impl/deftype.cljc"
|
||||
"impl/records.cljc" "impl/core_protocols.cljc" "impl/hierarchies.cljc"
|
||||
"impl/namespaces.cljc" "core.cljc"]
|
||||
(load-file ctx (string sci-base "/" file)))
|
||||
|
||||
# ── Verify sci.lang NS and Type ─────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue