[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Warn about comparing quoted lists (etc) using `eq`
From: |
Mattias Engdegård |
Subject: |
Warn about comparing quoted lists (etc) using `eq` |
Date: |
Wed, 14 Dec 2022 19:17:07 +0100 |
I'm about to push a new byte-compiler warning that finds mistakes like
(eq x '(ho hum))
Ie, attempts to compare, by identity, literals that may not match anything at
all: quoted lists, strings, floats etc.
The warning finds about 20 such mistakes in the Emacs tree, including two by
this programmer. So far no false positives have turned up, although not all
warnings indicate actual bugs (many things just happen to work by luck).
Typically the remedy is to use equal instead of eq, and so on.
The warning applies to arguments in calls to eq, eql, memq, memql, assq, rassq,
remq and delq.
Given its usefulness and low risk (it does not actually change the behaviour of
anything) I suggest it be added to the emacs-29 branch. Objections? (Clearly
we'd like to fix the mistakes found in emacs-29, and doing so is a lot more
convenient if the warning is actually there too.)
Patch below for reference. I don't think it merits a NEWS entry but could
certainly add one.
0001-Warn-about-unmatchable-constant-args-to-eq-memq-etc.patch
Description: Binary data
- Warn about comparing quoted lists (etc) using `eq`,
Mattias Engdegård <=