~ chicken-core (chicken-5) 1564a4600c69c0db6b9be97bbda518e725121f75
commit 1564a4600c69c0db6b9be97bbda518e725121f75 Author: Peter Bex <peter.bex@xs4all.nl> AuthorDate: Thu Aug 9 20:55:24 2012 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Fri Aug 10 10:58:34 2012 +0200 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 Signed-off-by: felix <felix@call-with-current-continuation.org> diff --git a/expand.scm b/expand.scm index 1e137b98..660d1fa5 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 833d1ed9..cc5f246c 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 fileTrap