mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 06:41:13 +02:00
fix bug bindings lexical vars within optargs initializers
* module/language/tree-il/analyze.scm (analyze-lexicals): Fix bug in which variables bound within inits were being improperly allocated. * module/language/tree-il/compile-glil.scm (vars->bind-list): More detail in terrible debugging clause. * test-suite/tests/optargs.test ("lambda* inits"): Add tests for binding vars within inits.
This commit is contained in:
parent
b597129782
commit
9a9d82c28c
3 changed files with 14 additions and 2 deletions
|
@ -388,7 +388,7 @@
|
||||||
(allocate! body proc n)
|
(allocate! body proc n)
|
||||||
;; inits not logically at the end, but they
|
;; inits not logically at the end, but they
|
||||||
;; are the list...
|
;; are the list...
|
||||||
(map (lambda (x) (allocate! x body n)) inits))))
|
(map (lambda (x) (allocate! x proc n)) inits))))
|
||||||
;; label and nlocs for the case
|
;; label and nlocs for the case
|
||||||
(hashq-set! allocation x (cons (gensym ":LCASE") nlocs))
|
(hashq-set! allocation x (cons (gensym ":LCASE") nlocs))
|
||||||
nlocs)
|
nlocs)
|
||||||
|
|
|
@ -173,7 +173,7 @@
|
||||||
(pmatch (hashq-ref (hashq-ref allocation v) proc)
|
(pmatch (hashq-ref (hashq-ref allocation v) proc)
|
||||||
((#t ,boxed? . ,n)
|
((#t ,boxed? . ,n)
|
||||||
(list id boxed? n))
|
(list id boxed? n))
|
||||||
(,x (error "badness" x))))
|
(,x (error "badness" id v x))))
|
||||||
ids
|
ids
|
||||||
vars))
|
vars))
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,18 @@
|
||||||
(equal? (f 1 2 3 #:x 'x #:z 'z)
|
(equal? (f 1 2 3 #:x 'x #:z 'z)
|
||||||
'(x #f z (1 2 3 #:x x #:z z))))))
|
'(x #f z (1 2 3 #:x x #:z z))))))
|
||||||
|
|
||||||
|
(with-test-prefix/c&e "lambda* inits"
|
||||||
|
(pass-if "can bind lexicals within inits"
|
||||||
|
(begin
|
||||||
|
(define* (qux #:optional a
|
||||||
|
#:key (b (or a 13) #:a))
|
||||||
|
b)
|
||||||
|
#t))
|
||||||
|
(pass-if "testing qux"
|
||||||
|
(and (equal? (qux) 13)
|
||||||
|
(equal? (qux 1) 1)
|
||||||
|
(equal? (qux #:a 2) 2))))
|
||||||
|
|
||||||
(with-test-prefix/c&e "defmacro*"
|
(with-test-prefix/c&e "defmacro*"
|
||||||
(pass-if "definition"
|
(pass-if "definition"
|
||||||
(begin
|
(begin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue