1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +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
parent 08bb462836
commit b56e084c77
No known key found for this signature in database
GPG key ID: 7CEF29847562C516

View file

@ -1585,11 +1585,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))