From: Glenn Morris <rgm@gnu.org>
To: IRIE Shinsuke <irieshinsuke@yahoo.co.jp>
Cc: 5950@debbugs.gnu.org
Subject: bug#5950: defvaralias after defvar should be warned in runtime
Date: Wed, 15 Sep 2010 16:16:03 -0400 [thread overview]
Message-ID: <vp62y6n4os.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <4BC6A096.8030801@yahoo.co.jp> (IRIE Shinsuke's message of "Thu\, 15 Apr 2010 14\:13\:58 +0900")
IRIE Shinsuke wrote:
> We assume an user wrote .emacs file as:
>
> (setq old-foo 123)
> (load "bar")
>
> Here, bar.el includes the following:
>
> (defvar foo 456)
> (define-obsolete-variable-alias 'old-foo 'foo)
>
> By this .emacs setting, the user probably hopes `old-foo' remains 123
> after loading bar.el, but actually it will be changed to 456.
[...]
> I think the programs like bar.el should be warned when running (and
> byte-compiling, if possible).
You can never have too many compilation warnings...
Here is an attempt at this. Comments:
1) It gives a spurious warning in cases where the
define-obsolete-variable-alias statement is autoloaded. One could
simply reposition such statements anyway.
2) I never know when to use normal-call or keep-pending.
It does reveal a couple of bugs in the current trunk.
*** lisp/emacs-lisp/bytecomp.el 2010-09-15 15:30:43 +0000
--- lisp/emacs-lisp/bytecomp.el 2010-09-15 18:59:50 +0000
***************
*** 3874,3879 ****
--- 3874,3892 ----
(byte-compile-set-symbol-position 'lambda)
(error "`lambda' used as function name is invalid"))
+ (put 'define-obsolete-variable-alias 'byte-hunk-handler
+ 'byte-compile-define-obsolete-variable-alias)
+ ;; Gives a spurious warning if the d-o-v-a is autoloaded.
+ (defun byte-compile-define-obsolete-variable-alias (form)
+ (and (byte-compile-warning-enabled-p 'suspicious)
+ (eq (car-safe (nth 2 form)) 'quote)
+ (memq (car-safe (cdr (nth 2 form))) byte-compile-bound-variables)
+ (not (memq (cadr (nth 2 form)) byte-compile-const-variables))
+ (byte-compile-warn "variable `%s' aliased after definition"
+ (cadr (nth 2 form))))
+ (byte-compile-keep-pending form)
+ nil)
+
;; Compile normally, but deal with warnings for the function being defined.
(put 'defalias 'byte-hunk-handler 'byte-compile-file-form-defalias)
(defun byte-compile-file-form-defalias (form)
next prev parent reply other threads:[~2010-09-15 20:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-15 5:13 bug#5950: defvaralias after defvar should be warned in runtime IRIE Shinsuke
2010-09-15 20:16 ` Glenn Morris [this message]
2010-09-16 0:44 ` IRIE Shinsuke
2010-09-16 3:51 ` Glenn Morris
2010-09-16 9:27 ` Stefan Monnier
2018-05-26 16:52 ` Noam Postavsky
2018-05-26 19:46 ` Stefan Monnier
2018-05-26 23:54 ` Noam Postavsky
2018-06-12 11:48 ` Noam Postavsky
[not found] ` <cb864996-c592-5507-f0c6-be07d17f13ee@gmail.com>
[not found] ` <jwvlg9pkbip.fsf-monnier+emacs@gnu.org>
2018-08-02 13:08 ` Clément Pit-Claudel
2018-08-02 13:28 ` Noam Postavsky
2018-08-02 14:37 ` Clément Pit-Claudel
2018-08-02 17:03 ` Stefan Monnier
2018-08-03 3:33 ` Clément Pit-Claudel
2018-08-03 20:23 ` Noam Postavsky
2018-08-03 21:00 ` Clément Pit-Claudel
2018-08-03 22:09 ` Noam Postavsky
2018-08-03 22:24 ` Clément Pit-Claudel
2018-08-03 21:58 ` Stefan Monnier
2018-08-02 2:14 ` Noam Postavsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vp62y6n4os.fsf@fencepost.gnu.org \
--to=rgm@gnu.org \
--cc=5950@debbugs.gnu.org \
--cc=irieshinsuke@yahoo.co.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.