Consider the following Common Lisp code.
(print (let* ((x nil) (y x)) (setq x t) (and y x))) ; T
(print (let* ((x nil) (y x)) (setq x t) (and x y))) ; NIL
(print (let* ((x nil) (y t)) (setq y x) (setq x t) (and y x))) ; NIL
(defun noop (x) (when x (princ "")))
(print (let* ((x nil) (y x)) (noop y) (setq x t) (and y x))) ; NIL
(print (let* ((x nil) (y x)) (setq x t) (noop y) (and y x))) ; NIL
Running the above code in SBCL 2.4.9 in linux, the first line prints T while the remaining lines print NIL. This online SBCL interpreter shows the same results. This is not the case in CLISP, for instance, where all the lines print NIL.
Why am I getting this seemingly strange result?
UPDATE 1: I reported this to the SBCL bug tracker: https://bugs.launchpad.net/sbcl/+bug/2092588
UPDATE 2: Apparently, one of the project's maintainers committed a fix for this bug in response to my report. That was really fast!
(DECLARE (OPTIMIZE ...))settings affect the result?