unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andrew Whatson <whatson@gmail.com>
To: guile-devel@gnu.org
Cc: Andrew Whatson <whatson@gmail.com>
Subject: [PATCH] Properly display locations in "source vector" form.
Date: Fri, 26 Aug 2022 19:50:21 +1000	[thread overview]
Message-ID: <20220826095021.2556-1-whatson@gmail.com> (raw)

Locations are stored in tree-il records in "source vector" form, but
`location-string' was rendering these as <unknown-location>.

* module/system/base/message.scm (location-string): Support locations
passed as a file/line/column vector.
---
 module/system/base/message.scm | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/module/system/base/message.scm b/module/system/base/message.scm
index 3cd862bd4..869afa783 100644
--- a/module/system/base/message.scm
+++ b/module/system/base/message.scm
@@ -41,12 +41,19 @@
 ;;;
 
 (define (location-string loc)
-  (if (pair? loc)
-      (format #f "~a:~a:~a"
-              (or (assoc-ref loc 'filename) "<stdin>")
-              (1+ (assoc-ref loc 'line))
-              (assoc-ref loc 'column))
-      "<unknown-location>"))
+  (define (format-loc file line column)
+    (format #f "~a:~a:~a"
+            (or file "<stdin>")
+            (1+ line)
+            column))
+  (match loc
+    (#(file line column)
+     (format-loc file line column))
+    ((? pair? loc)
+     (format-loc (assoc-ref loc 'filename)
+                 (assoc-ref loc 'line)
+                 (assoc-ref loc 'column)))
+    (_ "<unknown-location>")))
 
 \f
 ;;;
-- 
2.37.2




             reply	other threads:[~2022-08-26  9:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26  9:50 Andrew Whatson [this message]
2022-08-26 10:50 ` [PATCH] Properly display locations in "source vector" form lloda
2022-08-26 10:54   ` Jean Abou Samra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220826095021.2556-1-whatson@gmail.com \
    --to=whatson@gmail.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).