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

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 16 Mar 2018 03:43:02 +0000

Your bug report

#29520: peval leaves behind dangling lexical reference

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
29520: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29520
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#29520: peval leaves behind dangling lexical reference
From: Mark H Weaver <[email-masked]>
To: Stefan Israelsson Tampe <[email-masked]>
Cc: [email-masked]
Date: Thu, 15 Mar 2018 23:41:32 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

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

Subject: Compilation error.
From: Stefan Israelsson Tampe <[email-masked]>
To: [email-masked]
Date: Fri, 1 Dec 2017 13:08:46 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Consider the code at the end of this post. un-commenting f-scope reveals
the compiler error:

;;; ERROR: unbound lexical #<tree-il (lexical x #{x 190}#)>

But without it the globalified versoin f-scope2 comiles just fine
indicating an error in the compiler.

Regards
Stefan

(define-syntax-rule (<p-lambda> (c) code ...) (lambda (a b cc d c) code
...))
(define-syntax ..
  (syntax-rules ()
    ((.. (f a ...)) (f x y z a ...))
    ((.. (s ...) (f a ...))
     (f x y z a ...))))
#;
(define (f-scope f)
  (define (g f x3)
    (define (h x2 n m)
      (lambda xx (apply (f-skip n m) x2)))
    (<p-lambda> (c)
      (.. (c2) (f c))
      (let ((n N) (m M))
        (.. ((h x3 n m) c2)))))

  (lambda x (apply (g f x) x)))

(define (h x2 n m)
  (lambda xx (apply (f-skip n m) x2)))

(define (g f x3)
  (<p-lambda> (c)
    (.. (c2) (f c))
    (let ((n N) (m M))
      (.. ((h x3 n m) c2)))))

(define (f-scope2 f)
  (lambda x (apply (g f x) x)))