On Sat, Jul 20, 2019 at 11:51:28AM +0300, megane wrote:
> Here's a new patch that drops the (not captured) check.

Thanks for making that!  Now that my original patch has been pushed,
here's an incremental patch based on yours which only drops that check.

Cheers,
Peter
From 03000b61cfd13bffe809c0908b2144f86a4f49f0 Mon Sep 17 00:00:00 2001
From: Peter Bex <pe...@more-magic.net>
Date: Sun, 25 Aug 2019 16:23:11 +0200
Subject: [PATCH] Also allow captured variables with known values from being
 replaced

This should still be safe.  Only when the variable is assigned to is
this not allowed.

This change should completely fix situations like in #1620
---
 core.scm | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/core.scm b/core.scm
index bd36448b..2fce485b 100644
--- a/core.scm
+++ b/core.scm
@@ -2368,21 +2368,24 @@
 			undefined) )
 	   (quick-put! plist 'removable #t) )
 
-	 ;; Make 'replacable, if it has a variable as known value and if either that variable has
-	 ;;  a known value itself, or the target and the source are never assigned and the source
-	 ;;  is non-global or we are in block-mode:
-	 ;;  - The target-variable is not allowed to be global.
+	 ;; Make 'replacable, if
+	 ;; - it has a variable as known value and
+	 ;; - it is not a global
+	 ;; - it is never assigned to and
+	 ;; - if either the substitute has a known value itself or
+	 ;;   * the substitute is never assigned to and
+	 ;;   * we are in block-mode or the substitute is non-global
+	 ;;
 	 ;;  - The variable that can be substituted for the current one is marked as 'replacing.
 	 ;;    This is done to prohibit beta-contraction of the replacing variable (It wouldn't be there, if
 	 ;;    it was contracted).
 	 (when (and value (not global))
 	   (when (eq? '##core#variable (node-class value))
 	     (let ((name (first (node-parameters value))) )
-	       (when (and (not captured)
+	       (when (and (not assigned)
 			  (or (and (not (db-get db name 'unknown))
 				   (db-get db name 'value))
-			      (and (not assigned)
-				   (not (db-get db name 'assigned))
+			      (and (not (db-get db name 'assigned))
 				   (or (not (variable-visible?
 					     name block-compilation))
 				       (not (db-get db name 'global))) ) ))
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to