Lexical Binding, DEFUN inside LET - bound value changes without being set?

Bug #1653370 reported by Rainer Joswig on 2016-12-31
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

SBCL 1.3.11 on a Mac.

;-------------------------

(defun f ()
  (print :f0))

(let ((old-f #'f))
  (funcall old-f)
  (defun f () (print :f1))
  (funcall old-f))

;-------------------------

Loading/executing the above code prints

:F0
:F1

I would expect:

:F0
:F0

The funcall should call the same function object both times.

;-------------------------

(defun f ()
  (print :f0))

(let ((old-f #'f))
  (setf old-f #’f) ;; added
  (funcall old-f)
  (defun f () (print :f1))
  (funcall old-f))

;-------------------------

Above then prints:

:F0
:F0

Setting the variable to the same value it is already bound to then doesn't show the error.
Declaring the old-f variable to be special also avoids the error.

Stas Boukarev (stassats) wrote :

This is basically the same as https://bugs.launchpad.net/sbcl/+bug/1289779

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

Other bug subscribers