Skip to content

Commit

Permalink
package locks and compile-time effects of DEFCLASS
Browse files Browse the repository at this point in the history
  DEFCLASS FTYPE used to break SBCL, but package locks didn't catch it.
  • Loading branch information
nikodemus committed Dec 30, 2011
1 parent ddc81e7 commit 737f1f3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -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:
Expand Down
12 changes: 7 additions & 5 deletions src/pcl/defclass.lisp
Expand Up @@ -298,6 +298,7 @@
;; 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
Expand All @@ -311,11 +312,12 @@
;; 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)
Expand Down
17 changes: 17 additions & 0 deletions tests/package-locks.impure.lisp
Expand Up @@ -550,4 +550,21 @@
(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.

0 comments on commit 737f1f3

Please sign in to comment.