package locks and compile-time effects of DEFCLASS
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 30 Dec 2011 12:54:52 +0000 (14:54 +0200)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 30 Dec 2011 12:54:52 +0000 (14:54 +0200)
  DEFCLASS FTYPE used to break SBCL, but package locks didn't catch it.

NEWS
src/pcl/defclass.lisp
tests/package-locks.impure.lisp

diff --git a/NEWS b/NEWS
index b9cffdf..e4ae3e1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -89,6 +89,8 @@ changes relative to sbcl-1.0.54:
     subtypes of CHARACTER that are forbidden according to ANSI. (lp#841312)
   * bug fix: missing failure-to-stack-allocate compiler notes for some
     forms of MAKE-ARRAY with dynamic-extent. (lp#902351)
+  * bug fix: some of the compile-time side-effects of DEFCLASS were not caught
+    by package locks.
 
 changes in sbcl-1.0.54 relative to sbcl-1.0.53:
   * minor incompatible changes:
index cd9bd18..e342b6e 100644 (file)
   ;; actual type as a compile-time side-effect would probably be a bad
   ;; idea and (2) anyway we don't need to modify it in order to make
   ;; NAME be recognized as a valid type name)
+  (with-single-package-locked-error (:symbol name "proclaiming ~S as a class"))
   (unless (info :type :kind name)
     ;; Tell the compiler to expect a class with the given NAME, by
     ;; writing a kind of minimal placeholder type information. This
            ;; that :WHERE-FROM is :DEFINED, not :DECLARED, and should
            ;; probably be factored into a common function -- eg.
            ;; (%proclaim-ftype name declared-or-defined).
-           (when (eq (info :function :where-from name) :assumed)
-             (proclaim-as-fun-name name)
-             (note-name-defined name :function)
-             (setf (info :function :where-from name) :defined
-                   (info :function :type name) type))))
+           (with-single-package-locked-error (:symbol name "proclaiming ~S as a function")
+             (when (eq (info :function :where-from name) :assumed)
+               (proclaim-as-fun-name name)
+               (note-name-defined name :function)
+               (setf (info :function :where-from name) :defined
+                     (info :function :type name) type)))))
     (let ((rtype (specifier-type '(function (t) t)))
           (wtype (specifier-type '(function (t t) t))))
       (dolist (reader readers)
index 3ba97a1..485f0ea 100644 (file)
     (assert (equal inline-lambda
                    (function-lambda-expression #'fill-pointer)))))
 
+(with-test (:name :compile-time-defclass-package-locked)
+  ;; Compiling (DEFCLASS FTYPE ...) used to break SBCL, but the package
+  ;; locks didn't kick in till later.
+  (assert (eq :ok
+              (handler-case
+                  (ctu:file-compile `((defclass ftype () ())))
+                (sb-ext:symbol-package-locked-error (e)
+                  (when (eq 'ftype (sb-ext:package-locked-error-symbol e))
+                    :ok)))))
+  ;; Check for accessor violations as well.
+  (assert (eq :ok
+              (handler-case
+                  (ctu:file-compile `((defclass foo () ((ftype :reader ftype)))))
+                (sb-ext:symbol-package-locked-error (e)
+                  (when (eq 'ftype (sb-ext:package-locked-error-symbol e))
+                    :ok))))))
+
 ;;; WOOT! Done.