Subject: Re: bug#27016: possible bug in `defsetf'

From: [email-masked]
Date: Mon, 22 May 2017 17:18:32 -0400

tags 27016 - unreproducible
found 27016 24.4
found 27016 25.2
quit

Rafael D Sorkin <[email-masked]> writes:

> Following your suggestion I tried starting with "emacs -Q" and
> got the same results as you did.  However if I (require 'cl)
> then the bug returns.  (I normally require CL automatically on
> starting emacs.)  So perhaps it's an incompatibility between CL
> and the new way that defsetf is implemented.

Oh, right, I see it now.  It happens in 24.4 and later.  I'm not sure
it's a bug though.  My guess is that the difference is eager
macroexpansion.  When I compile, then I get the same behaviour with 24.3
(that's my earliest working Emacs build) as well.

    $ emacs -Q -batch -l cl -f batch-byte-compile bug-27016-defsetf.el 

    In toplevel form:
    bug-27016-defsetf.el:1:1:Warning: cl package required at runtime
    bug-27016-defsetf.el:3:1:Warning: global/dynamic var `pair' lacks a prefix
    Wrote /home/npostavs/src/emacs/bug-27016-defsetf.elc
    $ emacs -Q -batch -l bug-27016-defsetf.elc
    pair: (0 . 4)

where bug-27016-defsetf.el has contents:

    (require 'cl)

    (defvar pair nil)
    (setq pair (cons 3 4))                  ; (3 . 4)
    (unless t
      (defalias 'foobar 'cons)
      (defsetf foobar setcar))              ; nil
    (setf (foobar pair) 0)                  ; 0       !

    (message "pair: %S" pair)