Can't reload the same defpackage when `:lock t` is specified
Reported by Robert Goldman on the mailing list.
(defpackage package-inferred-system-test/sbcl-ext-lock
(:use :cl)
#+(or sbcl ecl) (:lock t)
(:export #:implemented-by-other-package))
Executing this code twice leads to an lock violation error. After looking at the code the issue seems to be as follows:
defpackage
when redefining an existing package, first removes the USE list and then adds it anew, without checking whether it is idempotent. The first thing that comes to mind is checking whether SET-EXCLUSIVE-OR
is empty, and if so - leave the USE list as is.
> (format t "~&~@{~12@A ~S~%~}"
:version (lisp-implementation-version)
:vcs-id (ext:lisp-implementation-vcs-id)
:os (software-type)
:os-version (software-version)
:machine-type (machine-type)
:features *features*)
VERSION "23.9.9"
VCS-ID "ac89091af19f1755878be1742b86406493fca9c1"
OS "Linux"
OS-VERSION "6.6.6-1-default"
MACHINE-TYPE "x86_64"
FEATURES (:JD :QUICKLISP :ASDF-PACKAGE-SYSTEM :ASDF3.1 :ASDF3 :ASDF2 :ASDF
:OS-UNIX :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :WALKER :CDR-6
:GRAY-STREAMS-MODULE :CDR-1 :CDR-5 :LINUX :FORMATTER :CDR-7
:ECL-WEAK-HASH :LITTLE-ENDIAN :ECL-READ-WRITE-LOCK :LONG-LONG
:UINT64-T :UINT32-T :UINT16-T :COMPLEX-FLOAT :LONG-FLOAT :UNICODE
:DFFI :CLOS-STREAMS :CMU-FORMAT :UNIX :ECL-PDE :DLOPEN :CLOS
:THREADS :BOEHM-GC :ANSI-CL :COMMON-LISP
:FLOATING-POINT-EXCEPTIONS :IEEE-FLOATING-POINT
:PACKAGE-LOCAL-NICKNAMES :CDR-14 :PREFIXED-API :FFI :X86_64
:COMMON :ECL)
There's a related ASDF merge request in their repository here: https://gitlab.common-lisp.net/asdf/asdf/-/merge_requests/226 After fixing this issue it would be nice of us to ping them.
A quick glance at the manual did not show that we support the :lock t
option,
so it would be worth also documenting the feature and providing relevant tests.