mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 22:10:21 +02:00
better diagnostics on quasiquote errors
* module/system/il/compile.scm (constant?, codegen): Add some diagnostics so that we can get decent error reporting if we accidentally unquote an unreadable value into the compiled output.
This commit is contained in:
parent
2e7e6969bd
commit
1b79210aa2
1 changed files with 12 additions and 1 deletions
|
@ -102,6 +102,15 @@
|
|||
(make-glil-module op (ghil-var-env var) (ghil-var-name var)))
|
||||
(else (error "Unknown kind of variable:" var))))
|
||||
|
||||
(define (constant? x)
|
||||
(cond ((or (number? x) (string? x) (symbol? x) (keyword? x) (boolean? x)) #t)
|
||||
((pair? x) (and (constant? (car x))
|
||||
(constant? (cdr x))))
|
||||
((vector? x) (let lp ((i (vector-length x)))
|
||||
(or (zero? i)
|
||||
(and (constant? (vector-ref x (1- i)))
|
||||
(lp (1- i))))))))
|
||||
|
||||
(define (codegen ghil)
|
||||
(let ((stack '()))
|
||||
(define (push-code! loc code)
|
||||
|
@ -173,8 +182,10 @@
|
|||
((<ghil-unquote-splicing> env loc exp)
|
||||
(comp-push exp)
|
||||
(push-call! #f 'list-break '()))))
|
||||
((constant? x)
|
||||
(push-code! #f (make-glil-const #:obj x)))
|
||||
(else
|
||||
(push-code! #f (make-glil-const #:obj x)))))
|
||||
(error "element of quasiquote can't be compiled" x))))
|
||||
(maybe-drop)
|
||||
(maybe-return))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue