weird compilation effects with progn + defclass + macro
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Invalid
|
Undecided
|
Unassigned |
Bug Description
;; Code:
(require 'closer-mop) ;; 1
(defmacro gen () ;; 2
(let ((type (sb-mop:
(unless (equal type 'boolean) (error "No type specified for the slot."))))
(progn ;; 3
(defclass A () ((x :type boolean))) ;; (x :type boolean) -> (x)
(c2mop:
(gen))
#|
1. eval-defun expressions 1 and 2
2. compile-defun expression 3
3. observe error: "no class named common-
4. compile-defun again, error is gone
5. remove type specification in class A
6. compile-defun expression 3, observe no error (should be error)
7. compile-defun expression 3 again, observe error "No type specified for the slot"
unlike compile-defun, eval-defun produces expected behavior.
What's happening here?
SBCL 2.0.5
Linux archbox 5.7.9-arch1-1 #1 SMP PREEMPT Thu, 16 Jul 2020 19:34:49 +0000 x86_64 GNU/Linux
(:SLYNK :QUICKLISP :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF :OS-UNIX
:NON-BASE-
:COMMON-LISP :ELF :IEEE-FLOATING-
:PACKAGE-
:SB-THREAD :SB-UNICODE :SBCL :UNIX)
|#
You are defining the class and expanding the macro at different times, so each time you edit your form the macro gets the previous definition.