From f77874a59e016706ca73f6acec0ea03dc71fc54a Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Mon, 15 May 2017 20:14:42 +0200 Subject: [PATCH 2/4] Use the raw variable name in env lookups and errors The current-environment and the macro-environment are alists whose keys are the raw variable names. Also reword the error messages a little. --- core.scm | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/core.scm b/core.scm index 8f68e3fa..5af0cd7c 100644 --- a/core.scm +++ b/core.scm @@ -1107,24 +1107,25 @@ (set! val `(let ((,var ,val)) (##core#debug-event "C_DEBUG_GLOBAL_ASSIGN" ',var) - ,var)))) - (cond ((##sys#macro? var) - (warning - (sprintf "~aassigned global variable `~S' is syntax" - (if ln (sprintf "(~a) - " ln) "") - var)) - (when undefine-shadowed-macros (##sys#undefine-macro! var))) - ((and ##sys#notices-enabled - (assq var (##sys#current-environment))) - (##sys#notice - (sprintf "~aassignment to imported value binding `~S'" - (if ln (sprintf "(~a) - " ln) "") - var)))) - (when (keyword? var) - (warning - (sprintf "~aassignment to keyword `~S'" - (if ln (sprintf "(~a) - " ln) "") - var))) + ,var))) + ;; We use `var0` instead of `var` because the {macro,current}-environment + ;; are keyed by the raw and unqualified name + (cond ((##sys#macro? var0 se) + (warning + (sprintf "~aassignment to syntax `~S'" + (if ln (sprintf "(~a) - " ln) "") + var0)) + (when undefine-shadowed-macros (##sys#undefine-macro! var0))) + ((assq var0 (##sys#current-environment)) + (warning + (sprintf "~aassignment to imported value binding `~S'" + (if ln (sprintf "(~a) - " ln) "") + var0))) + ((keyword? var0) + (warning + (sprintf "~aassignment to keyword `~S'" + (if ln (sprintf "(~a) - " ln) "") + var0))))) `(set! ,var ,(walk val e se var0 (memq var e) h ln #f)))))) ((##core#debug-event) -- 2.13.0