1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-13 00:50:26 +00:00

Fix bug in pretty printing.

This commit is contained in:
Calvin Rose 2018-11-30 11:46:05 -05:00
parent f8ab60f487
commit 523d909cca
2 changed files with 4 additions and 4 deletions

View File

@ -891,7 +891,7 @@ value, one key will be ignored."
[xs] [xs]
(flatten-into @[] xs)) (flatten-into @[] xs))
(defn dict-seq (defn kvs
"Takes a table or struct and returns and array of key value pairs "Takes a table or struct and returns and array of key value pairs
like @[k v k v ...]. Returns a new array." like @[k v k v ...]. Returns a new array."
[dict] [dict]
@ -1408,6 +1408,6 @@ value, one key will be ignored."
(some uqs? x) (tuple tuple.slice (tuple.prepend (map uqs x) array.concat)) (some uqs? x) (tuple tuple.slice (tuple.prepend (map uqs x) array.concat))
(apply tuple tuple (map qq x))) (apply tuple tuple (map qq x)))
:array (apply array (map qq x)) :array (apply array (map qq x))
:struct (apply struct (map qq (dict-seq x))) :struct (apply struct (map qq (kvs x)))
:table (apply table (map qq (dict-seq x))) :table (apply table (map qq (kvs x)))
x)) x))

View File

@ -505,7 +505,7 @@ static void janet_pretty_one(struct pretty *S, Janet x) {
Janet seenid = janet_table_get(&S->seen, x); Janet seenid = janet_table_get(&S->seen, x);
if (janet_checktype(seenid, JANET_INTEGER)) { if (janet_checktype(seenid, JANET_INTEGER)) {
janet_buffer_push_cstring(S->buffer, "<cycle "); janet_buffer_push_cstring(S->buffer, "<cycle ");
integer_to_string_b(S->buffer, janet_unwrap_integer(x)); integer_to_string_b(S->buffer, janet_unwrap_integer(seenid));
janet_buffer_push_u8(S->buffer, '>'); janet_buffer_push_u8(S->buffer, '>');
return; return;
} else { } else {