Clean up compiler self-lint warnings

This commit is contained in:
2026-04-04 16:42:51 +02:00
parent 8488cab0ac
commit f085882a4a

View File

@@ -6,7 +6,6 @@
(define-module (gulie compiler) (define-module (gulie compiler)
#:use-module (system base compile) #:use-module (system base compile)
#:use-module (ice-9 match)
#:use-module (ice-9 regex) #:use-module (ice-9 regex)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (gulie diagnostic) #:use-module (gulie diagnostic)
@@ -60,32 +59,43 @@ Filters out warnings attributed to files other than FILE."
((string-contains msg "cannot be meaningfully") 'bad-case-datum) ((string-contains msg "cannot be meaningfully") 'bad-case-datum)
(else 'compiler-warning))) (else 'compiler-warning)))
(define (display-raw-exception-args port args)
(for-each (lambda (a)
(display a port)
(display " " port))
args))
(define (format-exception-message key args) (define (format-exception-message key args)
"Format compiler exception KEY and ARGS into a readable string." "Format compiler exception KEY and ARGS into a readable string."
(call-with-output-string (call-with-output-string
(lambda (p) (lambda (p)
(display key p) (display key p)
(display ": " p) (display ": " p)
(catch #t (let ((subr (and (pair? args) (car args)))
(lambda () (fmt (and (pair? args)
(match args (pair? (cdr args))
((subr fmt fmt-args . _) (cadr args)))
(when subr (fmt-args (and (pair? args)
(display subr p) (pair? (cdr args))
(display ": " p)) (pair? (cddr args))
(if fmt-args (caddr args))))
(apply format p fmt (if (list? fmt-args) (catch #t
fmt-args (lambda ()
(list fmt-args))) (if fmt
(display fmt p))) (begin
(_ (for-each (lambda (a) (when subr
(display a p) (display " " p)) (display subr p)
args)))) (display ": " p))
(lambda _ (if fmt-args
;; Fallback: just display the raw args (apply format p fmt
(for-each (lambda (a) (if (list? fmt-args)
(display a p) (display " " p)) fmt-args
args)))))) (list fmt-args)))
(display fmt p)))
(display-raw-exception-args p args)))
(lambda _
;; Fallback: just display the raw args
(display-raw-exception-args p args)))))))
(define (source-location-ref loc key . default) (define (source-location-ref loc key . default)
(let ((pair (and (list? loc) (assq key loc)))) (let ((pair (and (list? loc) (assq key loc))))