~ chicken-core (master) c4f6f5e7fdb4826bdda39192d591ff305b7a42dd
commit c4f6f5e7fdb4826bdda39192d591ff305b7a42dd
Author: Peter Bex <peter@more-magic.net>
AuthorDate: Thu Oct 22 11:56:53 2026 +0200
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Thu Oct 22 21:30:19 2026 +0200
Fix finalizer test so it works with the new finalizer semantics
This test set a finalizer on an object with a lambda in a containing
let expression containing that object. Because let expressions
compile in the interpreter to a "display vector", they hold on to all
the values which are bound by the let. This display vector is also
closed over by lambdas, which means they retain the values inside.
This caused the test to fail because the lambda of the finalizer would
hang on to the finalizable value, so it could never be collected.
Signed-off-by: felix <felix@call-with-current-continuation.org>
diff --git a/tests/test-finalizers.scm b/tests/test-finalizers.scm
index b59ce476..c7e64757 100644
--- a/tests/test-finalizers.scm
+++ b/tests/test-finalizers.scm
@@ -49,8 +49,11 @@ a fix that unfortunately disables finalizers in the interpreter
(define foo-f #f)
-(let ((foo (vector 1 2 3)))
- (set-finalizer! foo (lambda _ (set! foo-f #t)))
+(let ((foo (vector 1 2 3))
+ ;; NOTE: foo should not be in scope for f, as the lambda retains
+ ;; this info via its display vector
+ (f (lambda _ (set! foo-f #t))))
+ (set-finalizer! foo f)
#t)
(gc #t)
Trap