From 3abdab1bbbc8e77f7b94e88ec3d1761bdc52be79 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Thu, 29 Nov 2012 22:28:43 +0100 Subject: [PATCH] In LET/LET* do not replace a read-only variable when its value is a global variable and is used more than once --- src/cmp/cmplet.lsp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cmp/cmplet.lsp b/src/cmp/cmplet.lsp index dc706d9b4..9c23ff8f6 100644 --- a/src/cmp/cmplet.lsp +++ b/src/cmp/cmplet.lsp @@ -170,7 +170,9 @@ ;; - the value of e2 is not modified in e3 nor in following expressions (when (eq (c1form-name form) 'VAR) (let ((other-var (c1form-arg 0 form))) - (unless (or (member other-var rest-vars) + (unless (or (and (global-var-p other-var) + (> (var-ref var) 1)) + (member other-var rest-vars) (var-changed-in-form-list other-var rest-forms)) (cmpdebug "Replacing variable ~A by its value ~A" (var-name var) form) (nsubst-var var form)