Global variable and class variable conflict
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Hi,
in sbcl2.3.3
CL-USER> (defparameter b 20)
(defclass foo()
((a :initarg :a)
(b :initarg :b)))
(defmethod initialize-instance :after((f foo)&key)
(with-slots (a b) f
(setf a (loop for i from 0 below b collect i))))
; in: DEFMETHOD INITIALIZE-INSTANCE :AFTER (FOO)
; (SYMBOL-MACROLET ((A (SLOT-VALUE #:G184 'A)) (B (SLOT-VALUE #:G184 'B)))
; (LET ((#:G188 #:G184))
; (FUNCALL #'(SB-PCL:
; (BLOCK NIL
; (LET #
; #
; #))
; #:G188)))
;
; caught ERROR:
; Attempt to bind a special variable with SYMBOL-MACROLET: B
;
; compilation unit finished
; caught 1 ERROR condition
#<STANDARD-METHOD COMMON-
The behavior of SBCL is precisely as specified; and not only that, this code will similarly fail in ABCL, CLISP, Clozure, and ECL, with minor variations (e.g. failing at method definition time or method execution time)
There's a reason that special vars should follow the asterisk naming convention which makes it unlikely to conflict by accident.