Subject: bug#5950: defvaralias after defvar should be warned in runtime

From: Clément Pit-Claudel <[email-masked]>
Date: Fri, 3 Aug 2018 17:00:33 -0400

On 2018-08-03 16:23, Noam Postavsky wrote:
> On 2 August 2018 at 23:33, Clément Pit-Claudel <[email-masked]> wrote:
>> On 2018-08-02 13:03, Stefan Monnier wrote:
>>>>> The typical failure case goes like this, user does this:
>>>>>
>>>>> (setq the-package-setting 'foo)
>>>>> (require 'the-package)
>>>>>
>>>>> And the-package.el does this:
>>>>>
>>>>> (defvar the-package-real-setting 'bar)
>>>>> ;; Oops! User's setting of `foo' is overwritten here:
>>>>> (defvaralias 'the-package-setting 'the-package-real-setting)
>>>>
>>>> Thanks.  Should the warning be disabled when both variables are
>>>> already `defvar'd, then?
>>>
>>> Why?  Replace `setq` with `defvar` in the above scenario and you have
>>> the same problem.
>>
>> Do you? I thought the problem was that you were overwriting a user setting… if you change the first setq into a defvar, where's the user setting that you're overwriting?
> 
> If the user writes defvar instead of setq, it has the exact same
> effect: they've set the-package-setting to foo, which will be
> overwritten to bar, same as before.

Right, I understand that.  But why would a user write 'defvar' to set a user variable?
I guess I'm just a bit confused by the warning.  What's the proper way to resolve it?  Should I create the alias before loading flycheck?