Add missing side-effect-free and error-free properties

Any function that is pure is also side-effect-free and some are also
error-free.  Right now these have to be declared separately.

* lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add
bool-vector-count-consecutive, bool-vector-count-population,
bool-vector-subsetp, copysign, isnan, lax-plist-get, ldexp, memql,
regexp-opt and string-to-syntax.
(side-effect-and-error-free-fns): Add type-of.
* lisp/subr.el (kbd, string-replace): Declare side-effect-free.
This commit is contained in:
Mattias Engdegård 2020-11-01 15:57:12 +01:00
parent d860168493
commit d85e0df7ad
2 changed files with 12 additions and 10 deletions

View file

@ -1147,12 +1147,14 @@
(let ((side-effect-free-fns
'(% * + - / /= 1+ 1- < <= = > >= abs acos append aref ash asin atan
assq
bool-vector-count-consecutive bool-vector-count-population
bool-vector-subsetp
boundp buffer-file-name buffer-local-variables buffer-modified-p
buffer-substring byte-code-function-p
capitalize car-less-than-car car cdr ceiling char-after char-before
char-equal char-to-string char-width compare-strings
compare-window-configurations concat coordinates-in-window-p
copy-alist copy-sequence copy-marker cos count-lines
copy-alist copy-sequence copy-marker copysign cos count-lines
current-time-string current-time-zone
decode-char
decode-time default-boundp default-value documentation downcase
@ -1165,22 +1167,22 @@
frame-visible-p fround ftruncate
get gethash get-buffer get-buffer-window getenv get-file-buffer
hash-table-count
int-to-string intern-soft
int-to-string intern-soft isnan
keymap-parent
length line-beginning-position line-end-position
lax-plist-get ldexp length line-beginning-position line-end-position
local-variable-if-set-p local-variable-p locale-info
log log10 logand logb logcount logior lognot logxor lsh
make-byte-code make-list make-string make-symbol marker-buffer max
member memq min minibuffer-selected-window minibuffer-window
member memq memql min minibuffer-selected-window minibuffer-window
mod multibyte-char-to-unibyte next-window nth nthcdr number-to-string
parse-colon-path plist-get plist-member
prefix-numeric-value previous-window prin1-to-string propertize
degrees-to-radians
radians-to-degrees rassq rassoc read-from-string regexp-quote
region-beginning region-end reverse round
radians-to-degrees rassq rassoc read-from-string regexp-opt
regexp-quote region-beginning region-end reverse round
sin sqrt string string< string= string-equal string-lessp
string-search string-to-char
string-to-number substring
string-to-number string-to-syntax substring
sxhash sxhash-equal sxhash-eq sxhash-eql
symbol-function symbol-name symbol-plist symbol-value string-make-unibyte
string-make-multibyte string-as-multibyte string-as-unibyte
@ -1230,7 +1232,7 @@
standard-case-table standard-syntax-table stringp subrp symbolp
syntax-table syntax-table-p
this-command-keys this-command-keys-vector this-single-command-keys
this-single-command-raw-keys
this-single-command-raw-keys type-of
user-real-login-name user-real-uid user-uid
vector vectorp visible-frame-list
wholenump window-configuration-p window-live-p

View file

@ -896,7 +896,7 @@ This is the same format used for saving keyboard macros (see
For an approximate inverse of this, see `key-description'."
;; Don't use a defalias, since the `pure' property is true only for
;; the calling convention of `kbd'.
(declare (pure t))
(declare (pure t) (side-effect-free t))
;; A pure function is expected to preserve the match data.
(save-match-data (read-kbd-macro keys)))
@ -4446,7 +4446,7 @@ Unless optional argument INPLACE is non-nil, return a new string."
(defun string-replace (fromstring tostring instring)
"Replace FROMSTRING with TOSTRING in INSTRING each time it occurs."
(declare (pure t))
(declare (pure t) (side-effect-free t))
(when (equal fromstring "")
(signal 'wrong-length-argument fromstring))
(let ((start 0)