optimized constructors don't see constant redefinitions

Bug #1644944 reported by 3b on 2016-11-26
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Low
Unassigned

Bug Description

from _death on #lisp (http://paste.lisp.org/display/332457)

CL-USER> (defconstant meaning-of-universe 41)
MEANING-OF-UNIVERSE
CL-USER> (defclass encapsulated ()
           ((thing :initarg :thing :reader thing)))
#<STANDARD-CLASS COMMON-LISP-USER::ENCAPSULATED>
CL-USER> (defun encapsulate ()
           (make-instance 'encapsulated
                          :thing meaning-of-universe))
ENCAPSULATE
CL-USER> (thing (encapsulate))
41
CL-USER> (defconstant meaning-of-universe 42) ;; pick 'continue' restart
MEANING-OF-UNIVERSE
CL-USER> meaning-of-universe
42
CL-USER> (defun encapsulate ()
           (make-instance 'encapsulated
                          :thing meaning-of-universe))
WARNING: redefining COMMON-LISP-USER::ENCAPSULATE in DEFUN
ENCAPSULATE
CL-USER> (thing (encapsulate))
41
CL-USER> (lisp-implementation-version)
"1.3.11"

While redefining the constant is technically non-conformant, not seeing the new definition in a function compiled after the redefinition makes the continue restart less useful.

from #sbcl:

<scymtym> from a brief look, the MAKE-INSTANCE gets an optimized constructor
          which is cached with the constant symbol as part of the key, leading
          to the redefined function getting the same constructor [19:52]

Jan Moringen (scymtym) on 2016-11-27
Changed in sbcl:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → Jan Moringen (scymtym)
Jan Moringen (scymtym) on 2016-12-11
Changed in sbcl:
status: Confirmed → Fix Committed
assignee: Jan Moringen (scymtym) → nobody
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers