diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2018-04-20 17:22:47 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2018-04-20 17:22:47 -0400 |
commit | 495963cfaf535646350051f47c085b84319572f0 (patch) | |
tree | 41cbcf9016d33124ea845c0c352731cf4a49d11c /lisp/emacs-lisp | |
parent | 71b108a5d771a5d9a777dd9bdafa082fa6a6384b (diff) | |
download | emacs-495963cfaf535646350051f47c085b84319572f0.tar.gz emacs-495963cfaf535646350051f47c085b84319572f0.tar.bz2 emacs-495963cfaf535646350051f47c085b84319572f0.zip |
* lisp/emacs-lisp/bytecomp.el (byte-compile-file-form-defvar-function):
Warn about defvaralias that follows instead of precedes its var.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index ea9e3f06555..50e67046e8b 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2426,6 +2426,15 @@ list that represents a doc string reference. (defun byte-compile-file-form-defvar-function (form) (pcase-let (((or `',name (let name nil)) (nth 1 form))) (if name (byte-compile--declare-var name))) + ;; Variable aliases are better declared before the corresponding variable, + ;; since it makes it more likely that only one of the two vars has a value + ;; before the `defvaralias' gets executed, which avoids the need to + ;; merge values. + (pcase form + (`(defvaralias ,_ ',newname . ,_) + (when (memq newname byte-compile-bound-variables) + (byte-compile-warn + "Alias for `%S' should be declared before its referent" newname)))) (byte-compile-keep-pending form)) (put 'custom-declare-variable 'byte-hunk-handler |