bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47080: 28.0.50; Spurious variable left uninitialized compiler warnin


From: Stefan Monnier
Subject: bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning
Date: Thu, 11 Mar 2021 21:58:51 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Lars Ingebrigtsen [2021-03-12 01:23:01] wrote:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
>> Compiling gives me:
>> | compile-test.el:6:1: Warning: Variable `file' left uninitialized
>> | compile-test.el:6:1: Warning: Variable `file' left uninitialized
>
> This is perhaps the same problem that's causing this warning on the
> current Emacs trunk?

Indeed.

> In toplevel form:
> progmodes/sh-script.el:1050:1: Warning: Variable `syntax' left uninitialized

I just fixed this one.

> I was just looking at this, and it looks like a spurious warning, if I
> read the syntax-propertize-rules correctly.

The warning complains when you initially bind a lexical var to nil
(either by not giving a value or by giving an explicit nil) and then
never set it to any other value.

Indeed, it's a useless binding: you could just use nil instead wherever
you use that var, so the warning is working as intended.  And indeed, it
found a few places where we bound a var to nil and then just
returned its value (and it's thanks to this warning that I discovered
that those var needed to be declared as dynamically scoped).

But the above `pcase` and `syntax-propertize-rules` show that it can be
quite inconvenient.  I can probably fix `pcase` to work around the
issue, but ... it's probably better to tone down the warning so it's
only issued if the nil binding is implicit rather than explicit.


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]