fix: REPL lazy-seq printer walks full chain (capped); def/defn return var (prints #'ns/name); fix var-name printer bug

This commit is contained in:
Yogthos 2026-06-04 14:55:11 -04:00
parent b78e61bf5c
commit 77c52553cb
4 changed files with 24 additions and 16 deletions

View file

@ -9,3 +9,4 @@
{"id":"int-677fb0a5","kind":"field_change","created_at":"2026-06-04T18:40:42.396722Z","actor":"Yogthos","issue_id":"jolt-40n","extra":{"field":"status","new_value":"closed","old_value":"open"}}
{"id":"int-10c63325","kind":"field_change","created_at":"2026-06-04T18:40:43.31635Z","actor":"Yogthos","issue_id":"jolt-4z9","extra":{"field":"status","new_value":"closed","old_value":"open"}}
{"id":"int-ba29d2c7","kind":"field_change","created_at":"2026-06-04T18:45:52.297233Z","actor":"Yogthos","issue_id":"jolt-gxr","extra":{"field":"status","new_value":"closed","old_value":"open"}}
{"id":"int-b7e06923","kind":"field_change","created_at":"2026-06-04T18:55:10.600885Z","actor":"Yogthos","issue_id":"jolt-7n5","extra":{"field":"status","new_value":"closed","old_value":"open"}}

View file

@ -11,5 +11,5 @@
{"_type":"issue","id":"jolt-9sb","title":"HIGH: destructuring gaps (nested seq, :strs, nested map, fn-param)","status":"closed","priority":2,"issue_type":"bug","owner":"yogthos@gmail.com","created_at":"2026-06-04T18:09:55Z","created_by":"Yogthos","updated_at":"2026-06-04T18:31:24Z","closed_at":"2026-06-04T18:31:24Z","dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"jolt-7dy","title":"MED: compiler path lacks IFn dispatch (collections-as-fn) — only interpreter fixed","status":"open","priority":3,"issue_type":"bug","owner":"yogthos@gmail.com","created_at":"2026-06-04T18:10:00Z","created_by":"Yogthos","updated_at":"2026-06-04T18:10:00Z","dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"jolt-90c","title":"MED: filter/take-while not lazy — infinite-seq (take N (filter p (range))) loops","status":"open","priority":3,"issue_type":"bug","owner":"yogthos@gmail.com","created_at":"2026-06-04T18:10:00Z","created_by":"Yogthos","updated_at":"2026-06-04T18:10:00Z","dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"jolt-7n5","title":"MED: REPL display — def/defn should print #'ns/name; lazy-seq printer realizes only head ((0 \u003cfunction\u003e))","status":"open","priority":3,"issue_type":"bug","owner":"yogthos@gmail.com","created_at":"2026-06-04T18:09:59Z","created_by":"Yogthos","updated_at":"2026-06-04T18:09:59Z","dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"jolt-7n5","title":"MED: REPL display — def/defn should print #'ns/name; lazy-seq printer realizes only head ((0 \u003cfunction\u003e))","status":"closed","priority":3,"issue_type":"bug","owner":"yogthos@gmail.com","created_at":"2026-06-04T18:09:59Z","created_by":"Yogthos","updated_at":"2026-06-04T18:55:11Z","closed_at":"2026-06-04T18:55:11Z","dependency_count":0,"dependent_count":0,"comment_count":0}
{"_type":"issue","id":"jolt-h0n","title":"MED: missing core fns — letfn fnil trampoline doseq cycle partition-all reductions dedupe keep-indexed map-indexed transduce reduce-kv assoc-in peek subvec read-string format","status":"open","priority":3,"issue_type":"feature","owner":"yogthos@gmail.com","created_at":"2026-06-04T18:09:58Z","created_by":"Yogthos","updated_at":"2026-06-04T18:09:58Z","dependency_count":0,"dependent_count":0,"comment_count":0}

View file

@ -485,7 +485,8 @@
(bind-root v val)
(when dynamic?
(put v :dynamic true))
(var-get v))
# def returns the var (Clojure semantics); REPL prints #'ns/name
v)
"defmacro" (let [name-sym (in form 1)
rest-form (tuple/slice form 2)
# optional docstring

View file

@ -3,6 +3,7 @@
(use ./api)
(use ./types)
(use ./phm)
(def ctx (init))
(ctx-set-current-ns ctx "user")
@ -32,21 +33,26 @@
(++ i)))
(push-str buf "]"))
# LazySeq — realize and print as a list
# LazySeq — realize the cell chain and print as a list. Capped to avoid
# hanging on infinite sequences; prints "..." when truncated.
(and (table? v) (= :jolt/lazy-seq (v :jolt/type)))
(do
(def val (if (get v :realized) (v :val) (let [vf ((v :fn))] (put v :realized true) (put v :val vf) vf)))
(if (nil? val)
(push-str buf "()")
(do
(push-str buf "(")
(var i 0)
(let [n (length val)]
(while (< i n)
(write-value (in val i) buf)
(when (< (+ i 1) n) (push-str buf " "))
(++ i)))
(push-str buf ")"))))
(push-str buf "(")
(var cur v)
(var i 0)
(var go true)
(while (and go (< i 1000))
(let [cell (realize-ls cur)]
(if (or (nil? cell) (= :jolt/pending cell) (= 0 (length cell)))
(set go false)
(do
(when (> i 0) (push-str buf " "))
(write-value (in cell 0) buf)
(++ i)
(let [rt (in cell 1)]
(if (nil? rt) (set go false) (set cur (make-lazy-seq rt))))))))
(when (and go (>= i 1000)) (push-str buf " ..."))
(push-str buf ")"))
(array? v)
(do
@ -119,7 +125,7 @@
(push-str buf (string ns "/" name))
(push-str buf name)))
(and (table? v) (= :jolt/var (v :jolt/type)))
(push-str buf (string "#'" (ctx-current-ns ctx) "/" ((var-name v) :name)))
(push-str buf (string "#'" (ctx-current-ns ctx) "/" (var-name v)))
(or (tuple? v) (array? v) (struct? v) (table? v))
(write-collection v buf)
true (push-str buf (string v)))))