1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Properly display locations in "source vector" form.

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.
This commit is contained in:
Andrew Whatson 2022-08-26 11:50:21 +02:00 committed by Daniel Llorens
parent c746586de3
commit eb5ecf4944

View file

@ -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>")))
;;;