From 7b079d36d3cbf5749e3938e54f8865cc86c66b49 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 23 Jul 2020 12:38:01 -0400 Subject: [PATCH] Pretty-up the top-level error messages Make the output more readable when we have location information for the error. --- cyclone.scm | 8 +++++++- scheme/base.sld | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cyclone.scm b/cyclone.scm index 045df06b..56752cf3 100644 --- a/cyclone.scm +++ b/cyclone.scm @@ -955,7 +955,13 @@ Debug options: ;; pointless for users of the compiler, so we don't ;; want to display it. (parameterize ((current-output-port (current-error-port))) - (display "Error: ") + (cond + ((and (string? (car err)) + (equal? (substring (car err) 0 8) + "at line ")) + (display "Error ")) + (else + (display "Error: "))) (display (car err)) (display ": ") (newline) diff --git a/scheme/base.sld b/scheme/base.sld index b1a682ab..9386bb87 100644 --- a/scheme/base.sld +++ b/scheme/base.sld @@ -239,8 +239,8 @@ ;; Does reason already include line/file location info? (define (reason/line-loc? reason) (and (string? reason) - (equal? (substring reason 0 9) - "(at line "))) + (equal? (substring reason 0 8) + "at line "))) (let* ((found (assoc expr *source-loc-lis*)) (loc-vec (if found (cdr found) ;; Get value @@ -248,13 +248,13 @@ (msg (if (and loc-vec ;; Have line info (not (reason/line-loc? reason))) ;; Not there yet (string-append - "(at line " + "at line " (number->string (vector-ref loc-vec 1)) ", column " (number->string (vector-ref loc-vec 2)) " of " (vector-ref loc-vec 0) - ") " + ": " reason) reason))) (if (pair? args)