From 21dfbeb549968311391ae4b05bb2647ed08aaf81 Mon Sep 17 00:00:00 2001
From: Peter Bex <peter.bex@xs4all.nl>
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
|
b
|
|
877 | 877 | (lambda (name) |
878 | 878 | (dd "STRIP SYNTAX ON " sym " ---> " name) |
879 | 879 | name)) |
880 | | (else (dd "BUILTIN ALIAS:" renamed) renamed)))))) |
| 880 | ;; Rename builtin aliases so strip-syntax can still |
| 881 | ;; access symbols as entered by the user |
| 882 | (else (let ((implicitly-renamed (rename sym))) |
| 883 | (dd "BUILTIN ALIAS: " sym " as " renamed |
| 884 | " --> " implicitly-renamed) |
| 885 | implicitly-renamed))))))) |
881 | 886 | (if explicit-renaming? |
882 | 887 | ;; Let the user handle renaming |
883 | 888 | (handler form rename compare) |
diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm
index 833d1ed..cc5f246 100644
a
|
b
|
take |
1041 | 1041 | (lambda (e r c) |
1042 | 1042 | `(,(r 'list) ,(r 'define)))))) |
1043 | 1043 | |
1044 | | (f (eval '(begin (import renamed-macros) (renamed-macro-not-firstclassed)))) |
1045 | | No newline at end of file |
| 1044 | (f (eval '(begin (import renamed-macros) (renamed-macro-not-firstclassed)))) |
| 1045 | |
| 1046 | ;; #893: implicitly renamed variables shouldn't be resolved to core |
| 1047 | ;; builtins (#%xyz), but go through a level of indirection, so |
| 1048 | ;; strip-syntax can still access the original symbol. |
| 1049 | (module rename-builtins |
| 1050 | (strip-syntax-on-*) |
| 1051 | (import chicken scheme) |
| 1052 | (define-syntax strip-syntax-on-* |
| 1053 | (ir-macro-transformer |
| 1054 | (lambda (e r c) '(quote *))))) |
| 1055 | |
| 1056 | (import rename-builtins) |
| 1057 | (assert (eq? '* (strip-syntax-on-*))) |
| 1058 | No newline at end of file |