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

Fix eta-conversion edge cases in peval.

Fixes <https://bugs.gnu.org/29520>.
Reported by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.

* module/language/tree-il/peval.scm (peval)[lift-applied-lambda]: Before
performing eta-conversion, check that the variable(s) passed to the
inner 'apply' are not referenced from the inner lambda, and that the
number of required arguments would not be reduced by the conversion.
This commit is contained in:
Mark H Weaver 2018-03-15 23:22:26 -04:00 committed by Andy Wingo
parent 2662cafd6a
commit 6708acbf66

View file

@ -1591,11 +1591,15 @@ top-level bindings from ENV and return the resulting expression."
(and (not opt) rest (not kw)
(match body
(($ <primcall> _ 'apply
(($ <lambda> _ _ (and lcase ($ <lambda-case>)))
(($ <lambda> _ _ (and lcase ($ <lambda-case> _ req1)))
($ <lexical-ref> _ _ sym)
...))
(and (equal? sym gensyms)
(not (lambda-case-alternate lcase))
(<= (length req) (length req1))
(every (lambda (s)
(= (lexical-refcount s) 1))
sym)
lcase))
(_ #f))))
(let* ((vars (map lookup-var gensyms))