Fix REPL: tuple rendering via struct? collision
Janet's struct? returns true for tuples, causing print-value's symbol-struct check to call (get tuple :jolt/type) which fails with 'expected integer key for tuple...got :name'. Fix: reorder cond in print-value — check tuple? and array? before struct? checks. Split (or tuple? array? struct? table?) into individual arms so cond stops at the first match. ( range 10) now renders [0 1 2 3 4 5 6 7 8 9] instead of error. 315 ok, 2 fail (pre-existing, unchanged)
This commit is contained in:
parent
281810837a
commit
5cd9c47fe8
1 changed files with 7 additions and 1 deletions
|
|
@ -94,12 +94,18 @@
|
|||
(number? v) (prin v)
|
||||
(string? v) (prin v)
|
||||
(keyword? v) (prin ":") (prin (string v))
|
||||
(tuple? v)
|
||||
(do (print-collection v) (print))
|
||||
(array? v)
|
||||
(do (print-collection v) (print))
|
||||
(and (struct? v) (= :symbol (get v :jolt/type)))
|
||||
(let [ns (get v :ns) name (get v :name)]
|
||||
(if ns (prin ns "/" name) (prin name)))
|
||||
(and (table? v) (= :jolt/var (v :jolt/type)))
|
||||
(prin "#'" (ctx-current-ns ctx) "/" ((var-name v) :name))
|
||||
(or (tuple? v) (array? v) (struct? v) (table? v))
|
||||
(struct? v)
|
||||
(do (print-collection v) (print))
|
||||
(table? v)
|
||||
(do (print-collection v) (print))
|
||||
(print v))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue