[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 22:29:08 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Lars Ingebrigtsen [2021-03-12 04:07:47] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> 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).
>
> Oh, is that what the warning means. :-) It's not immediately
> obvious -- could it be changed to something like... er... "Variable
> bound to constant value and not changed"?
Indeed, the warning could even be generalized to other trivial constant
values like `t`, but I think what we have already gives enough false
positives ;-)
[ Still, I'm quite happy with the warning in that it pointed me to a few
actual problems in the code. The average usefulness rating of each
of the warnings that I fixed after adding this warning was not too bad. ]
As for changing the wording, feel free: I'm not too happy with the
current one either (after all, the variables are initialized to nil in
any case, so there's no such thing as an uninitialized variable),
tho I'm not very fond of the one you suggest.
In any case I installed the patch below which should fix the immediate
offenders.
Stefan
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index ca641a2ef0..cfb0168a6e 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -602,7 +602,8 @@ cconv--analyze-use
(byte-compile-warn
"%s `%S' not left unused" varkind var))
((and (let (or 'let* 'let) (car form))
- `(,(or `(,var) `(,var nil)) t nil ,_ ,_))
+ `(,`(,var) ;; (or `(,var nil) : Too many false positives: bug#47080
+ t nil ,_ ,_))
;; FIXME: Convert this warning to use `macroexp--warn-wrap'
;; so as to give better position information.
(unless (not (intern-soft var))
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Michael Heerdegen, 2021/03/11
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Lars Ingebrigtsen, 2021/03/11
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Michael Heerdegen, 2021/03/11
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Stefan Monnier, 2021/03/11
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Lars Ingebrigtsen, 2021/03/11
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning,
Stefan Monnier <=
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Michael Heerdegen, 2021/03/12
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Stefan Monnier, 2021/03/12
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Michael Heerdegen, 2021/03/12
- bug#47080: 28.0.50; Spurious variable left uninitialized compiler warning, Stefan Monnier, 2021/03/12