Global variable and class variable conflict

Bug #2015615 reported by xizang
6
This bug affects 1 person
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::SLOT-ACCESSOR :GLOBAL A SB-PCL::WRITER)
; (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-LISP:INITIALIZE-INSTANCE :AFTER (FOO) {10085207F3}>

Revision history for this message
Douglas Katzman (dougk) wrote :

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.

Changed in sbcl:
status: New → Invalid
Revision history for this message
xizang (xizang) wrote :

ok, thanks!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.