GNU bug report logs - #5950
defvaralias after defvar should be warned in runtime

Previous Next

Package: emacs;

Reported by: irieshinsuke <at> yahoo.co.jp

Date: Thu, 15 Apr 2010 05:15:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #42 received at 5950 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: 5950 <at> debbugs.gnu.org
Cc: Clément Pit-Claudel <cpitclaudel <at> gmail.com>
Subject: Re: bug#5950: defvaralias after defvar should be warned in runtime
Date: Wed, 01 Aug 2018 22:14:05 -0400
[Message part 1 (text/plain, inline)]
[forwarding to list, original didn't make it because bug was archived]

[Message part 2 (message/rfc822, inline)]
From: Clément Pit-Claudel <cpitclaudel <at> gmail.com>
To: Noam Postavsky <npostavs <at> gmail.com>, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#5950: defvaralias after defvar should be warned in runtime
Date: Wed, 1 Aug 2018 14:55:56 -0400
Hi Noam,

I just updated my Emacs and ran into this warning, but I have no idea
what's wrong with the following code :)

  (defvaralias 'flycheck-python-pylint-executable 'python-shell-interpreter)
  (defvaralias 'flycheck-python-flake8-executable 'python-shell-interpreter)

These two variables `flycheck-&-executable' are configuration knobs
created by Flycheck, and I never want to set them individually; instead,
I want them to have the same value as `python-shell-interpreter'.  While
the code above works, it also pops a "warning" buffer now:

Warning (defvaralias): Overwriting value of ‘flycheck-python-pylint-executable’ by aliasing to ‘python-shell-interpreter’
Warning (defvaralias): Overwriting value of ‘flycheck-python-flake8-executable’ by aliasing to ‘python-shell-interpreter’

I've set warning-suppress-log-types to '(defvaralias losing-value) to
work around this, but was the warning actually intended in this case?

Clément.
[Message part 3 (text/plain, inline)]

It's warning because you overwrite the original value of
flycheck-python-pylint-executable when you call defvaralias.  In this
case you intended that, but usually it's a mistake.

You could make the warning suppression more selective by adding
(defvaralias losing-value flycheck-python-pylint-executable) and
(defvaralias losing-value flycheck-python-flake8-executable) to
warning-suppress-log-types.

Alternatively, you could do

  (setq flycheck-python-pylint-executable python-shell-interpreter)
  (defvaralias 'flycheck-python-pylint-executable 'python-shell-interpreter)
  (setq flycheck-python-flake8-executable python-shell-interpreter)
  (defvaralias 'flycheck-python-flake8-executable 'python-shell-interpreter)

(the warning doesn't trigger if the value being overwritten is `eq' to
the new one).


This bug report was last modified 6 years and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.