branch: elpa/sly commit 8074da031ed9d677abc77fb3dab4bb42c6be76c3 Author: daewok <dae...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
Fix #492: Rework handling of SBCL's package variance warning Recompiling slynk-backend.lisp and slynk.lisp causes SBCL to emit package variance warnings. Currently, these are handled by wrapping `(asdf:load-system "slynk")`. Unfortunately, this does not cover use cases where slynk is loaded as a dependency of another library. At least [40ants-doc][1] has added Slynk as a dependency, making it much more likely that Slynk will be recompiled outside of a call to load Slynk directly. We can handle this by moving the logic to handle the package variance warning to the :AROUND-COMPILE ASDF hook of the slynk-backend.lisp and slynk.lisp files. :AROUND-COMPILE with a LAMBDA was introduced in [ASDF 2.019][2]. If the minimum required ASDF version is bumped to something closer to ASDF 3, more (better) options become available to handle this, as noted in the comments. The only observable change should be that prior to this commit, `(asdf:load-system "slynk")` would signal a UIOP::COMPILE-WARNED-WARNING condition, but after this commit no warning at all is signaled and nothing is printed that indicates there was a warning. This is a bit unfortunate, as there could be other, non package-variance, warnings that would be silently missed. But it's the best I could come up with without requiring ASDF 3 or using a symbol from SB-INT. [1]: https://github.com/40ants/doc [2]: https://gitlab.common-lisp.net/asdf/asdf/-/blob/9dc59bb27c5251e954d6847cc1b507c5f399da7b/doc/Changelog#L984 --- slynk/slynk.asd | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/slynk/slynk.asd b/slynk/slynk.asd index 2043c8c9c8..97e7a2f0de 100644 --- a/slynk/slynk.asd +++ b/slynk/slynk.asd @@ -20,7 +20,16 @@ (defsystem :slynk :serial t :components - ((:file "slynk-backend") + ((:file "slynk-backend" + ;; If/when we require ASDF3, we can use UIOP:DEFINE-PACKAGE instead or use + ;; UIOP:MATCH-CONDITION-P to muffle only the package variance + ;; warning. Alternatively, SBCL could export the package variance warning + ;; from SB-EXT and we can muffle it directly. + #+sbcl :around-compile + #+sbcl #1=(lambda (thunk) + (handler-bind (((and warning (not style-warning)) #'muffle-warning)) + (let ((sb-ext:*on-package-variance* '(:warn t))) + (funcall thunk))))) ;; If/when we require ASDF3, we shall use :if-feature instead #+(or cmu sbcl scl) (:file "slynk-source-path-parser") @@ -60,7 +69,9 @@ (:file "slynk-gray") (:file "slynk-match") (:file "slynk-rpc") - (:file "slynk") + (:file "slynk" + #+sbcl :around-compile + #+sbcl #1#) (:file "slynk-completion") (:file "slynk-apropos"))) @@ -68,12 +79,6 @@ (format *debug-io* "~&SLYNK's ASDF loader finished.") (funcall (read-from-string "slynk::init"))) -#+sbcl -(defmethod operate :around ((o load-op) (c (eql (find-system :slynk))) &key &allow-other-keys) - (let ((asdf:*compile-file-failure-behaviour* :warn) - (sb-ext:*on-package-variance* '(:warn t))) - (call-next-method))) - ;;; Contrib systems (should probably go into their own file one day) ;;;