unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13814: 24.3.50; Dynamic variables shadowing prevent defvar
@ 2013-02-25 19:30 Jorgen Schaefer
  2013-02-25 23:15 ` Glenn Morris
  2013-02-26  0:03 ` Stefan Monnier
  0 siblings, 2 replies; 8+ messages in thread
From: Jorgen Schaefer @ 2013-02-25 19:30 UTC (permalink / raw)
  To: 13814

When a file is autoloaded, defvar will fail to define locally-set,
dynamic variabls, resulting in such variables not being defined at all,
even after their local binding ends.

Situation:

(let ((some-var-that-influences-behavior t))
  (some-function-that-autoloads-a-library))

If the library which is autoloaded by
`some-function-that-autoloads-a-library' defines
`some-var-that-influences-behavior' using defvar or defcustom, the
variable is never bound globally because defvar thinks it's already
defined.

I would expect defvar to notice that the variable is bound only
locally/temporarily and define a global binding anyhow.

Reproduction:

Put this file, bug-lib.el, somewhere in `load-path':

-----8<----- bug-lib.el -----8<----- 

(defvar bug-variable t
  "This variable is not defined when autoloaded.")

(defun bug-variable-value ()
  bug-variable)

----->8----- ---------- ----->8-----

Then execute the following lines:

(autoload 'bug-variable-value "bug-lib.el")

(let ((bug-variable nil))
  (bug-variable-value))

=> nil

(bug-variable-value)

=> Error, `bug-variable' is not defined.


Regards,
        -- Jorgen


In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu)
Bzr revision: 111608 schwab@linux-m68k.org-20130126151309-wk3nb8t4xitw94lh
Configured using:
 `configure --without-x --with-x-toolkit=no'





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-08-25 16:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-25 19:30 bug#13814: 24.3.50; Dynamic variables shadowing prevent defvar Jorgen Schaefer
2013-02-25 23:15 ` Glenn Morris
2013-02-26  0:03 ` Stefan Monnier
2021-08-23  1:21   ` Lars Ingebrigtsen
2021-08-24 21:25     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-25 11:00       ` Lars Ingebrigtsen
2021-08-25 14:41         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-25 16:03           ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).