From aa5698fb5350eb3bbc93f2569d3172a12376c523 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 29 Apr 2011 16:36:10 +0200 Subject: [PATCH] eval-when matches situations symbolically * module/ice-9/psyntax.scm (chi-when-list): Just match symbolically instead of lexically, so as not to tie the meaning of eval-when to the bindings of eval, load, compile, and expand. --- module/ice-9/psyntax.scm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm index 85ceb13c2..8232ad9f2 100644 --- a/module/ice-9/psyntax.scm +++ b/module/ice-9/psyntax.scm @@ -1066,20 +1066,21 @@ (define chi-when-list (lambda (e when-list w) - ;; when-list is syntax'd version of list of situations + ;; `when-list' is syntax'd version of list of situations. We + ;; could match these keywords lexically, via free-id=?, but then + ;; we twingle the definition of eval-when to the bindings of + ;; eval, load, expand, and compile, which is totally unintended. + ;; So do a symbolic match instead. (let f ((when-list when-list) (situations '())) (if (null? when-list) situations (f (cdr when-list) - (cons (let ((x (car when-list))) - (cond - ((free-id=? x #'compile) 'compile) - ((free-id=? x #'load) 'load) - ((free-id=? x #'eval) 'eval) - ((free-id=? x #'expand) 'expand) - (else (syntax-violation 'eval-when - "invalid situation" - e (wrap x w #f))))) + (cons (let ((x (syntax->datum (car when-list)))) + (if (memq x '(compile load eval expand)) + x + (syntax-violation 'eval-when + "invalid situation" + e (wrap (car when-list) w #f)))) situations)))))) ;; syntax-type returns six values: type, value, e, w, s, and mod. The