In LET/LET* do not replace a read-only variable when its value is a global variable and is used more than once

This commit is contained in:
Juan Jose Garcia Ripoll 2012-11-29 22:28:43 +01:00
parent 50d1c9fcf7
commit 3abdab1bbb

View file

@ -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)