[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] [PATCH] Fix #1620 by ignoring captured state of re
From: |
megane |
Subject: |
Re: [Chicken-hackers] [PATCH] Fix #1620 by ignoring captured state of replaced variables |
Date: |
Thu, 11 Jul 2019 15:15:00 +0300 |
User-agent: |
mu4e 1.0; emacs 25.1.1 |
megane <address@hidden> writes:
> Peter Bex <address@hidden> writes:
>
> Regarding the capturing, the capture test is still there:
>
>
>> (when (and value (not global))
>> (when (eq? '##core#variable (node-class value))
>> - (let* ((name (first (node-parameters value)))
>> - (nrefs (db-get db name 'references)) )
>> + (let ((name (first (node-parameters value))) )
>> (when (and (not captured)
> ^^^^^^^^^^^^^^
> Here.
> I got the impression you wanted to remove this.
>
Of course if this is dropped the other conditions must still meet.
Here's your proposed condition:
(and (not captured)
(or (and (not (db-get db name 'unknown))
(db-get db name 'value))
(and (not assigned)
(not (db-get db name 'assigned))
(or (not (variable-visible?
name block-compilation))
(not (db-get db name 'global))) )
))
If the (not captured) part is just dropped then if the first branch of
the or is taken, namely this:
(and (not (db-get db name 'unknown))
(db-get db name 'value))
then it's not checked that the variable to be replaced is never assigned
to! Here's a case that triggers the error:
(define (foo x)
(letrec ((pe* (lambda () (print x) (pe*))))
(pe*)))
(foo '((foo1 e)))
(foo 'foo2)
The letrec expands to an assignment and to a (##core#undefined) that
triggers the first branch of the or.
Here's a correct way to drop the (not captured) check:
(and (not assigned)
(or (and (not (db-get db name 'unknown))
(db-get db name 'value))
(and (not (db-get db name 'assigned))
(or (not (variable-visible?
name block-compilation))
(not (db-get db name 'global))) ) ))
Re: [Chicken-hackers] [PATCH] Fix #1620 by ignoring captured state of replaced variables,
megane <=