kadena-io / pact-5

The New Pact
BSD 3-Clause "New" or "Revised" License
8 stars 7 forks source link

Improve repl stack frame pretty printing #251

Closed jmcardon closed 2 weeks ago

jmcardon commented 4 weeks ago

While working on separate PRs, I noticed that it is incredibly annoying to sometimes fail with large callstacks, so I've fixed this.

Take this repl file function that simply fails with a callstack:

(defun fails-with-args (a b c k)
  (enforce false "boom")
)

(fails-with-args "a1u23123uh123uh123uh123uh123uh123123" (^ 2 10) 20 (enumerate 1 100))

Before this PR, this fails with:

Loaded repl defun fails-with-args
scratch/kek.repl:23:2: boom
 23 |   (enforce false "boom")
    |   ^^^^^^^^^^^^^^^^^^^^^^
  at (#repl.fails-with-args "a1u23123uh123uh123uh123uh123uh123123" 1024 20 [ 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
, 9
...

(I cut the output, it goes from 1 to 100)

After this PR:

Loaded repl defun fails-with-args
scratch/kek.repl:23:2: boom
 23 |   (enforce false "boom")
    |   ^^^^^^^^^^^^^^^^^^^^^^
  at (#repl.fails-with-args "a1u23123uh12..." 1024 20 [1 2 3 4 5 6 ...])

PR checklist:

Additionally, please justify why you should or should not do the following: