>From 21dfbeb549968311391ae4b05bb2647ed08aaf81 Mon Sep 17 00:00:00 2001 From: Peter Bex 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