bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65209: 30.0.50; Unexpected behaviour of setq-local


From: Stefan Monnier
Subject: bug#65209: 30.0.50; Unexpected behaviour of setq-local
Date: Sun, 13 Aug 2023 12:43:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> Evaluate the following
>
> (progn
>   (defvar my-var :default-value)
>   (make-variable-buffer-local 'my-var)
>   (let ((my-var :let-value))
>     (setq-local my-var :buffer-local-new))
>   my-var)
> => :default-value
>
> (progn
>   (defvar my-var1 :default-value)
>   (make-variable-buffer-local 'my-var1)
>   (setq my-var1 :buffer-local)
>   (let ((my-var1 :let-value))
>     (setq-local my-var1 :buffer-local-new))
>   my-var1)
> => :buffer-local
>
> In both cases, setq-local has no effect.

Hmm... this is a bug in `make-local-variable` where we do:

  if (blv ? blv->local_if_set
      : (forwarded && BUFFER_OBJFWDP (valcontents.fwd)))
    {
      tem = Fboundp (variable);
      /* Make sure the symbol has a local value in this particular buffer,
         by setting it to the same value it already has.  */
      Fset (variable, (EQ (tem, Qt) ? Fsymbol_value (variable) : Qunbound));
      return variable;
    }

I.e. we assume that if a var is `make-variable-buffer-local` then `set`
will make sure it has a buffer-local value, but this is not true if the
var is currently let-bound.

40 years after buffer-local and let-bindings were brought together and
we're still finding bugs :-(


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]