chicken-hackers
[Top][All Lists]
Advanced

[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: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Fix #1620 by ignoring captured state of replaced variables
Date: Thu, 11 Jul 2019 14:22:28 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

On Thu, Jul 11, 2019 at 03:15:00PM +0300, megane wrote:
> 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))) ) ))

Wow, nice catch!  That makes a lot of sense.  I'll cook up a proper
patch unless someone beats me to it.

Cheers,
Peter

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]