diff options
| author | Mistivia <i@mistivia.com> | 2025-06-22 17:32:33 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-06-22 17:32:33 +0800 |
| commit | 665fb6be7eef3703c8e543645d09f329b9a466c5 (patch) | |
| tree | b88691d2d2185a78a66f6725e2d5a8a96fc5d085 /src | |
| parent | 47c8353366c5cd7544d182a897bacaa303c08d8e (diff) | |
better assert
Diffstat (limited to 'src')
| -rw-r--r-- | src/primitives.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/primitives.c b/src/primitives.c index a0a90a0..1c0d1e3 100644 --- a/src/primitives.c +++ b/src/primitives.c @@ -6,7 +6,11 @@ SExpRef primitive_assert_error(Interp *interp, SExpRef args, bool istail) { SExpRef eargs = lisp_eval_args(interp, args); if (VALTYPE(eargs) == kErrSignal) return interp->t; - return new_error(interp, "assert-error failed: no error.\n"); + + const char *expstr = lisp_to_string(interp, CAR(args)); + SExpRef ret = new_error(interp, "assert-error failed, no error: %s.\n", expstr); + free((void*)expstr); + return ret; } SExpRef primitive_load(Interp *interp, SExpRef args, bool istail) { @@ -63,7 +67,7 @@ SExpRef primitive_assert(Interp *interp, SExpRef args, bool istail) { if (TRUEP(CAR(eargs))) { return interp->t; } else { - const char *expstr = lisp_to_string(interp, args); + const char *expstr = lisp_to_string(interp, CAR(args)); SExpRef ret = new_error(interp, "Assertion failed: %s.\n", expstr); free((void*)expstr); return ret; |
