Hi all, Megane found another modules & macros bug in the release candidate. I think this is potentially annoying enough to put in the fix before making a release (and the fix is conceptually simple enough too, IMO).
The attached patch ensures that symbols which correspond to builtins are not renamed directly to the core builtin name (#%* in the example. No, I'm not swearing, that's its name). The fix just adds another layer of indirection by implicitly renaming these symbols too, to avoid capture of the form by outer macros or procedures. All tests still pass, and the new test passes as well. Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth
>From 21dfbeb549968311391ae4b05bb2647ed08aaf81 Mon Sep 17 00:00:00 2001 From: Peter Bex <[email protected]> Date: Thu, 9 Aug 2012 20:55:24 +0200 Subject: [PATCH] Fix implicit renaming to avoid using core aliases directly; this wreaks havoc when later the original symbol needs to be retrieved. This fixes #893, reported by Megane --- expand.scm | 7 ++++++- tests/syntax-tests.scm | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/expand.scm b/expand.scm index 1e137b9..660d1fa 100644 --- a/expand.scm +++ b/expand.scm @@ -877,7 +877,12 @@ (lambda (name) (dd "STRIP SYNTAX ON " sym " ---> " name) name)) - (else (dd "BUILTIN ALIAS:" renamed) renamed)))))) + ;; Rename builtin aliases so strip-syntax can still + ;; access symbols as entered by the user + (else (let ((implicitly-renamed (rename sym))) + (dd "BUILTIN ALIAS: " sym " as " renamed + " --> " implicitly-renamed) + implicitly-renamed))))))) (if explicit-renaming? ;; Let the user handle renaming (handler form rename compare) diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm index 833d1ed..cc5f246 100644 --- a/tests/syntax-tests.scm +++ b/tests/syntax-tests.scm @@ -1041,4 +1041,17 @@ take (lambda (e r c) `(,(r 'list) ,(r 'define)))))) -(f (eval '(begin (import renamed-macros) (renamed-macro-not-firstclassed)))) \ No newline at end of file +(f (eval '(begin (import renamed-macros) (renamed-macro-not-firstclassed)))) + +;; #893: implicitly renamed variables shouldn't be resolved to core +;; builtins (#%xyz), but go through a level of indirection, so +;; strip-syntax can still access the original symbol. +(module rename-builtins + (strip-syntax-on-*) + (import chicken scheme) + (define-syntax strip-syntax-on-* + (ir-macro-transformer + (lambda (e r c) '(quote *))))) + +(import rename-builtins) +(assert (eq? '* (strip-syntax-on-*))) \ No newline at end of file -- 1.7.9.1
_______________________________________________ Chicken-hackers mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-hackers
