mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 13:30:26 +02:00
Simplify let-values to let if consumer binds only one variable
* module/language/tree-il/peval.scm (peval): let-values with a consumer that has only one argument is the same as let. * test-suite/tests/peval.test ("partial evaluation"): Add test.
This commit is contained in:
parent
4828538940
commit
64fc50c294
2 changed files with 10 additions and 1 deletions
|
@ -979,6 +979,10 @@ top-level bindings from ENV and return the resulting expression."
|
|||
;; reconstruct the let-values, pevaling the consumer.
|
||||
(let ((producer (for-values producer)))
|
||||
(or (match consumer
|
||||
(($ <lambda-case> src (req-name) #f #f #f () (req-sym) body #f)
|
||||
(for-tail
|
||||
(make-let src (list req-name) (list req-sym) (list producer)
|
||||
body)))
|
||||
(($ <lambda-case> src req opt rest #f inits gensyms body #f)
|
||||
(let* ((nmin (length req))
|
||||
(nmax (and (not rest) (+ nmin (if opt (length opt) 0)))))
|
||||
|
|
|
@ -1236,4 +1236,9 @@
|
|||
(call-with-prompt t
|
||||
(lambda () (abort-to-prompt t 1 2 3))
|
||||
(lambda (k x y z) (list x y z))))
|
||||
(primcall list (const 1) (const 2) (const 3))))
|
||||
(primcall list (const 1) (const 2) (const 3)))
|
||||
|
||||
(pass-if-peval
|
||||
(call-with-values foo (lambda (x) (bar x)))
|
||||
(let (x) (_) ((call (toplevel foo)))
|
||||
(call (toplevel bar) (lexical x _)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue