Subject: Re: bug#29520: peval leaves behind dangling lexical reference

From: Mark H Weaver <[email-masked]>
Date: Thu, 15 Mar 2018 23:41:32 -0400

Mark H Weaver <[email-masked]> writes:

> diff --git a/module/language/tree-il/peval.scm b/module/language/tree-il/peval.scm
> index 993fa0ad6..13b7d9bc4 100644
> --- a/module/language/tree-il/peval.scm
> +++ b/module/language/tree-il/peval.scm
> @@ -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))

Applied in commit b56e084c77914a7fde558e8fd28a218759a4ddd7 on the
stable-2.2 branch.  I'm closing this bug now, but feel free to reopen if
you still see related problems.

     Thanks!
       Mark