使用 SLIME 在 Aquamacs 中编译 SBCL defun 时出现类型错误

Type Error when compiling SBCL defun in Aquamacs with SLIME

这是我要编译的函数。它也是 lisp 文件中唯一的东西。

    (defun hello-world () (format t "hello world."))

我正在尝试用“^C ^C”编译函数。这是堆栈跟踪。

   The value NIL is not of type SB-C:POLICY.
       [Condition of type TYPE-ERROR]

    Restarts:
     0: [ABORT] Abort compilation.
     1: [*ABORT] Return to SLIME's top level.
     2: [ABORT] abort thread (#<THREAD "worker" RUNNING {1004247983}>)

    Backtrace:
      0: (SB-C::POLICY-TO-DECL-SPEC NIL T NIL)
          Locals:
            FORCE-ALL = NIL
            POLICY = NIL
            RAW = T
      1: (RESTRICT-COMPILER-POLICY NIL 0)
      2: (SWANK/SBCL::COMPILER-POLICY NIL)
      3: ((LABELS SWANK/SBCL::CF :IN SWANK/BACKEND:SWANK-COMPILE-STRING))
      4: ((FLET SWANK/BACKEND:CALL-WITH-COMPILATION-HOOKS :IN "/Users/colinmcd94/quicklisp/dists/quicklisp/software/slime-2.13/swank/sbcl.lisp") #<CLOSURE (LAMBDA NIL :IN SWANK/BACKEND:SWANK-COMPILE-STRING) {1..
      5: ((FLET SWANK/BACKEND:SWANK-COMPILE-STRING :IN "/Users/colinmcd94/quicklisp/dists/quicklisp/software/slime-2.13/swank/sbcl.lisp") "(defun hello-world () (format t \"hello world.\")) ..)
      6: ((LAMBDA NIL :IN SWANK:COMPILE-STRING-FOR-EMACS))
      7: ((LAMBDA NIL :IN SWANK::COLLECT-NOTES))
      8: (SWANK::MEASURE-TIME-INTERVAL #<CLOSURE (LAMBDA NIL :IN SWANK::COLLECT-NOTES) {1004258B2B}>)
      9: (SWANK::COLLECT-NOTES #<CLOSURE (LAMBDA NIL :IN SWANK:COMPILE-STRING-FOR-EMACS) {1004258AEB}>)
     10: (SWANK::CALL-WITH-BUFFER-SYNTAX NIL #<CLOSURE (LAMBDA NIL :IN SWANK:COMPILE-STRING-FOR-EMACS) {1004258AAB}>)
     11: (SB-INT:SIMPLE-EVAL-IN-LEXENV (SWANK:COMPILE-STRING-FOR-EMACS "(defun hello-world () (format t \"hello world.\")) ..)
     12: (EVAL (SWANK:COMPILE-STRING-FOR-EMACS "(defun hello-world () (format t \"hello world.\")) ..)
     13: (SWANK:EVAL-FOR-EMACS (SWANK:COMPILE-STRING-FOR-EMACS "(defun hello-world () (format t \"hello world.\")) ..)
     14: ((LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD))
     15: (SWANK/SBCL::CALL-WITH-BREAK-HOOK #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD) {1006B33B7B}>)
     16: ((FLET SWANK/BACKEND:CALL-WITH-DEBUGGER-HOOK :IN "/Users/colinmcd94/quicklisp/dists/quicklisp/software/slime-2.13/swank/sbcl.lisp") #<FUNCTION SWANK:SWANK-DEBUGGER-HOOK> #<FUNCTION (LAMBDA NIL :IN SWA..
     17: (SWANK::CALL-WITH-BINDINGS ((*STANDARD-OUTPUT* . #1=#<SWANK/GRAY::SLIME-OUTPUT-STREAM {1003B03FA3}>) (*STANDARD-INPUT* . #2=#<SWANK/GRAY::SLIME-INPUT-STREAM {1003A2C693}>) (*TRACE-OUTPUT* . #1#) (*ERR..
     18: ((LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD))
     19: ((FLET #:WITHOUT-INTERRUPTS-BODY-1182 :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
     20: ((FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE))
     21: ((FLET #:WITHOUT-INTERRUPTS-BODY-600 :IN SB-THREAD::CALL-WITH-MUTEX))
     22: (SB-THREAD::CALL-WITH-MUTEX #<CLOSURE (FLET SB-THREAD::WITH-MUTEX-THUNK :IN SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE) {820BCFB}> #<SB-THREAD:MUTEX "thread result lock" owner: #<SB-THREAD:THREAD "..
     23: (SB-THREAD::INITIAL-THREAD-FUNCTION-TRAMPOLINE #<SB-THREAD:THREAD "worker" RUNNING {1004247983}> NIL #<CLOSURE (LAMBDA NIL :IN SWANK::SPAWN-WORKER-THREAD) {100424792B}> (#<SB-THREAD:THREAD "worker" RU..
     24: ("foreign function: call_into_lisp")
     25: ("foreign function: new_thread_trampoline")
     26: ("foreign function: _pthread_body")
     27: ("foreign function: _pthread_body")
     28: ("foreign function: thread_start")

同样,这是 运行 Aquamacs with Slime,使用 SBCL。

运行 (sb-ext:restrict-compiler-policy 'debug) 是解决方法。

老实说,我不太了解为什么会这样,但确实如此。

现在 quicklisp 已更新,您可以将 :quicklisp-slime-helper 更新为 (ql:quickload :quicklisp-slime-helper),重新启动 SLIME,一切顺利。

您可能需要先 运行 (ql:update-client)(ql:update-all-dists),具体取决于上次更新后的时间。