~ chicken-core (chicken-5) ac38b9bae9349260cebdfb02ea9f0ef9217a225e
commit ac38b9bae9349260cebdfb02ea9f0ef9217a225e
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Wed Jul 22 10:55:43 2026 +0200
Commit: Peter Bex <peter@more-magic.net>
CommitDate: Wed Jul 22 11:47:18 2026 +0200
Modify global assignment debug-instrumentation at debug-level 3 to avoid shadowing of external callback
The instrumentation of code produced by debug level 3 ("-d3") resulted in the
name the compiler inferred for an external callback (via "define-external") to
be shadowed. This caused a mismatch when checking whether the Scheme entry
point of the callback name is in the compilers list of callbacks.
The result was that the entry point was not deemed to be special, with
the compiler then assuming it can optimize the procedure, including its argument
signature, arbitrarily, as no visible caller can be found when the callback is
defined inside a module.
The instrumentation code has now been restructured to avoid a temporary
wrapping of the "foreign-callback-wrapper" form.
Signed-off-by: Peter Bex <peter@more-magic.net>
diff --git a/core.scm b/core.scm
index 0a9b301e..c84fd997 100644
--- a/core.scm
+++ b/core.scm
@@ -1161,9 +1161,8 @@
(mark-variable var '##compiler#always-bound))
(when emit-debug-info
(set! val
- `(##core#let ((,var ,val))
- (##core#debug-event C_DEBUG_GLOBAL_ASSIGN (##core#quote ,var))
- ,var)))
+ `(##core#let ((,(gensym) (##core#debug-event C_DEBUG_GLOBAL_ASSIGN (##core#quote ,var))))
+ ,val)))
;; We use `var0` instead of `var` because the {macro,current}-environment
;; are keyed by the raw and unqualified name
(cond ((##sys#macro? var0 (##sys#current-environment))
Trap