1.0.29.16: make the fopcompiler DEFGLOBAL-aware
authorNikodemus Siivola <nikodemus@random-state.net>
Thu, 18 Jun 2009 09:32:45 +0000 (09:32 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Thu, 18 Jun 2009 09:32:45 +0000 (09:32 +0000)
* Thanks to Lars Rune Nøstdal.

NEWS
src/compiler/fopcompile.lisp
tests/defglobal.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 6530578..626b6d7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,8 @@
     Michael Becker, Gabriel Dos Reis, and Cyrus Harmon)
   * bug fix: :PTY option in RUN-PROGRAM was broken with stream arguments.
     (reported by Elliot Slaughter, thanks to Stas Boukarev)
+  * bug fix: bogus undefined variable warnings from fopcompiled references to
+    global variables. (thanks to Lars Rune Nøstdal)
 
 changes in sbcl-1.0.29 relative to 1.0.28:
   * IMPORTANT: bug database has moved from the BUGS file to Launchpad
index b1cbefe..266bcc6 100644 (file)
                ;; Symbol macro
                (fopcompile macroexpansion path for-value-p)
                (let ((kind (info :variable :kind form)))
-                 (if (member kind '(:special :constant))
-                     ;; Special variable
-                     (fopcompile `(symbol-value ',form) path for-value-p)
-                     ;; Lexical
-                     (let* ((lambda-var (cdr (assoc form (lexenv-vars *lexenv*))))
-                            (handle (when lambda-var
-                                      (lambda-var-fop-value lambda-var))))
-                       (if handle
-                           (when for-value-p
-                             (sb!fasl::dump-push handle *compile-object*))
-                           (progn
-                             ;; Undefined variable. Signal a warning, and
-                             ;; treat it as a special variable reference, like
-                             ;; the real compiler does -- do not elide even if
-                             ;; the value is unused.
-                             (note-undefined-reference form :variable)
-                             (fopcompile `(symbol-value ',form)
-                                         path
-                                         for-value-p)))))))))
+                 (cond
+                   ((eq :special kind)
+                    ;; Special variable
+                    (fopcompile `(symbol-value ',form) path for-value-p))
+
+                   ((member kind '(:global :constant))
+                    ;; Global variable or constant.
+                    (fopcompile `(symbol-global-value ',form) path for-value-p))
+                   (t
+                    ;; Lexical
+                    (let* ((lambda-var (cdr (assoc form (lexenv-vars *lexenv*))))
+                           (handle (when lambda-var
+                                     (lambda-var-fop-value lambda-var))))
+                      (if handle
+                          (when for-value-p
+                            (sb!fasl::dump-push handle *compile-object*))
+                          (progn
+                            ;; Undefined variable. Signal a warning, and
+                            ;; treat it as a special variable reference, like
+                            ;; the real compiler does -- do not elide even if
+                            ;; the value is unused.
+                            (note-undefined-reference form :variable)
+                            (fopcompile `(symbol-value ',form)
+                                        path
+                                        for-value-p))))))))))
         ((listp form)
          (multiple-value-bind (macroexpansion macroexpanded-p)
              (sb!xc:macroexpand form *lexenv*)
index 68a74e2..5b5e634 100644 (file)
       (ignore-errors (delete-file fasl)))
     (assert (= 1 *counter*))
     (assert (= 1 (symbol-value '.counter-3.)))))
+
+(with-test (:name :defglobal-refers-to-defglobal)
+  (let ((fasl (compile-form `(progn
+                               (defglobal **global-1** :fii)
+                               (defglobal **global-2** **global-1**)))))
+    (load fasl)
+    (assert (eq (symbol-value '**global-1**) (symbol-value '**global-2**)))
+    (assert (eq :fii (symbol-value '**global-1**)))))
index b8588b7..6b57f10 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.29.15"
+"1.0.29.16"